mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Dart 3.9 / Flutter 3.35 [first LLM release] (#2714)
I got carried away with Gemini and basically rewrote CI and the release process for the new LLM reality. This work was largely completed by Gemini. - Bump all SDK versions to the current beta (3.9.0-0) - Run `flutter channel beta` - Wrote `ci_script.dart` to replace the bash scripts - Converted repository to pub workspace #2499 - Added llm.md and release.md - Added redirect for deprecated Samples Index ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I have added sample code updates to the [changelog]. - [x] I updated/added relevant documentation (doc comments with `///`).
This commit is contained in:
@@ -22,7 +22,9 @@ class PlatformChannelSample extends StatelessWidget {
|
||||
return MaterialApp.router(
|
||||
title: 'Platform Channel Sample',
|
||||
theme: ThemeData(
|
||||
snackBarTheme: SnackBarThemeData(backgroundColor: Colors.blue[500]),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
backgroundColor: Colors.blue[500],
|
||||
),
|
||||
),
|
||||
routerConfig: router(),
|
||||
);
|
||||
|
||||
@@ -31,7 +31,10 @@ class _AddPetDetailsState extends State<AddPetDetails> {
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
PetListMessageChannel.addPetDetails(
|
||||
PetDetails(petType: petType, breed: breedTextController.text),
|
||||
PetDetails(
|
||||
petType: petType,
|
||||
breed: breedTextController.text,
|
||||
),
|
||||
);
|
||||
|
||||
context.pop();
|
||||
@@ -61,8 +64,14 @@ class _AddPetDetailsState extends State<AddPetDetails> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
RadioListTile<String>(title: const Text('Dog'), value: 'Dog'),
|
||||
RadioListTile<String>(title: const Text('Cat'), value: 'Cat'),
|
||||
RadioListTile<String>(
|
||||
title: const Text('Dog'),
|
||||
value: 'Dog',
|
||||
),
|
||||
RadioListTile<String>(
|
||||
title: const Text('Cat'),
|
||||
value: 'Cat',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -11,7 +11,9 @@ class Counter {
|
||||
/// Creates a [MethodChannel] with the specified name to invoke platform method.
|
||||
/// In order to communicate across platforms, the name of MethodChannel
|
||||
/// should be same on native and dart side.
|
||||
static MethodChannel methodChannel = const MethodChannel('methodChannelDemo');
|
||||
static MethodChannel methodChannel = const MethodChannel(
|
||||
'methodChannelDemo',
|
||||
);
|
||||
|
||||
/// This method is responsible to increment and return the value of count.
|
||||
static Future<int> increment({required int counterValue}) async {
|
||||
|
||||
@@ -15,7 +15,8 @@ class PlatformImageFetcher {
|
||||
|
||||
/// Method responsible for providing the platform image.
|
||||
static Future<Uint8List> getImage() async {
|
||||
final reply = await _basicMessageChannel.send('getImage') as Uint8List?;
|
||||
final reply =
|
||||
await _basicMessageChannel.send('getImage') as Uint8List?;
|
||||
if (reply == null) {
|
||||
throw PlatformException(
|
||||
code: 'Error',
|
||||
|
||||
@@ -39,7 +39,9 @@ class _MethodChannelDemoState extends State<MethodChannelDemo> {
|
||||
FilledButton.icon(
|
||||
onPressed: () async {
|
||||
try {
|
||||
final value = await Counter.increment(counterValue: count);
|
||||
final value = await Counter.increment(
|
||||
counterValue: count,
|
||||
);
|
||||
setState(() => count = value);
|
||||
} catch (error) {
|
||||
if (!context.mounted) return;
|
||||
@@ -58,7 +60,9 @@ class _MethodChannelDemoState extends State<MethodChannelDemo> {
|
||||
FilledButton.icon(
|
||||
onPressed: () async {
|
||||
try {
|
||||
final value = await Counter.decrement(counterValue: count);
|
||||
final value = await Counter.decrement(
|
||||
counterValue: count,
|
||||
);
|
||||
setState(() => count = value);
|
||||
} catch (error) {
|
||||
if (!context.mounted) return;
|
||||
|
||||
@@ -34,7 +34,9 @@ class PetListMessageChannel {
|
||||
/// we will throw a [PlatformException].
|
||||
static Future<void> removePet(int index) async {
|
||||
final uInt8List = utf8.encoder.convert(index.toString());
|
||||
final reply = await _binaryCodecChannel.send(uInt8List.buffer.asByteData());
|
||||
final reply = await _binaryCodecChannel.send(
|
||||
uInt8List.buffer.asByteData(),
|
||||
);
|
||||
if (reply == null) {
|
||||
throw PlatformException(
|
||||
code: 'INVALID INDEX',
|
||||
|
||||
@@ -56,10 +56,9 @@ class _PetListScreenState extends State<PetListScreen> {
|
||||
context.go('/petListScreen/addPetDetails');
|
||||
},
|
||||
),
|
||||
body:
|
||||
petListModel.petList.isEmpty
|
||||
? const Center(child: Text('Enter Pet Details'))
|
||||
: BuildPetList(petListModel.petList),
|
||||
body: petListModel.petList.isEmpty
|
||||
? const Center(child: Text('Enter Pet Details'))
|
||||
: BuildPetList(petListModel.petList),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,10 @@ class _PlatformImageDemoState extends State<PlatformImageDemo> {
|
||||
);
|
||||
} else if (snapshot.connectionState ==
|
||||
ConnectionState.done) {
|
||||
return Image.memory(snapshot.data!, fit: BoxFit.fill);
|
||||
return Image.memory(
|
||||
snapshot.data!,
|
||||
fit: BoxFit.fill,
|
||||
);
|
||||
}
|
||||
return const CircularProgressIndicator();
|
||||
},
|
||||
@@ -54,14 +57,13 @@ class _PlatformImageDemoState extends State<PlatformImageDemo> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton(
|
||||
onPressed:
|
||||
imageData != null
|
||||
? null
|
||||
: () {
|
||||
setState(() {
|
||||
imageData = PlatformImageFetcher.getImage();
|
||||
});
|
||||
},
|
||||
onPressed: imageData != null
|
||||
? null
|
||||
: () {
|
||||
setState(() {
|
||||
imageData = PlatformImageFetcher.getImage();
|
||||
});
|
||||
},
|
||||
child: const Text('Get Image'),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
name: platform_channels
|
||||
description: A new Flutter project.
|
||||
|
||||
version: 1.0.0+1
|
||||
resolution: workspace
|
||||
|
||||
environment:
|
||||
sdk: ^3.7.0-0
|
||||
sdk: ^3.9.0-0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
cupertino_icons: ^1.0.3
|
||||
go_router: ">=10.1.0 <17.0.0"
|
||||
go_router: ^16.0.0
|
||||
|
||||
dev_dependencies:
|
||||
analysis_defaults:
|
||||
path: ../analysis_defaults
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
|
||||
@@ -38,7 +38,10 @@ void main() {
|
||||
|
||||
// Navigate back to /petListScreen
|
||||
await tester.pumpAndSettle();
|
||||
expect(router.routeInformationProvider.value.uri.path, '/petListScreen');
|
||||
expect(
|
||||
router.routeInformationProvider.value.uri.path,
|
||||
'/petListScreen',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ void main() {
|
||||
|
||||
if (methodCall.method == 'listen') {
|
||||
// Emit new sensor values.
|
||||
emitValues(standardMethod.encodeSuccessEnvelope(sensorValues));
|
||||
emitValues(
|
||||
standardMethod.encodeSuccessEnvelope(sensorValues),
|
||||
);
|
||||
emitValues(null);
|
||||
return standardMethod.encodeSuccessEnvelope(null);
|
||||
} else if (methodCall.method == 'cancel') {
|
||||
|
||||
@@ -23,7 +23,9 @@ void main() {
|
||||
return MissingPluginException();
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(const MaterialApp(home: MethodChannelDemo()));
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(home: MethodChannelDemo()),
|
||||
);
|
||||
|
||||
// Initially the value of count should be 0.
|
||||
expect(find.text('Value of count is 0'), findsOneWidget);
|
||||
|
||||
@@ -26,7 +26,9 @@ void main() {
|
||||
setUpAll(() {
|
||||
// Mock for the pet list received from the platform.
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockDecodedMessageHandler(basicMessageChannel, (message) async {
|
||||
.setMockDecodedMessageHandler(basicMessageChannel, (
|
||||
message,
|
||||
) async {
|
||||
petListModel = PetListModel.fromJson(message!);
|
||||
return null;
|
||||
});
|
||||
@@ -78,7 +80,9 @@ void main() {
|
||||
|
||||
testWidgets('BuildPetList test', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(home: Scaffold(body: BuildPetList(petListModel!.petList))),
|
||||
MaterialApp(
|
||||
home: Scaffold(body: BuildPetList(petListModel!.petList)),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Pet type: Dog'), findsOneWidget);
|
||||
|
||||
@@ -16,11 +16,15 @@ void main() {
|
||||
StandardMessageCodec(),
|
||||
),
|
||||
(dynamic message) async {
|
||||
var byteData = await rootBundle.load('assets/eat_new_orleans.jpg');
|
||||
var byteData = await rootBundle.load(
|
||||
'assets/eat_new_orleans.jpg',
|
||||
);
|
||||
return byteData.buffer.asUint8List();
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(const MaterialApp(home: PlatformImageDemo()));
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(home: PlatformImageDemo()),
|
||||
);
|
||||
|
||||
// Initially a PlaceHolder is displayed when imageData is null.
|
||||
expect(find.byType(Placeholder), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user