1
0
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:
Eric Windmill
2025-08-14 12:26:24 -07:00
committed by GitHub
parent 0aa5415d5e
commit 2999d738b8
410 changed files with 28166 additions and 27661 deletions

View File

@@ -25,7 +25,8 @@ const double windowWidth = 400;
const double windowHeight = 800;
void setupWindow() {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
if (!kIsWeb &&
(Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
WidgetsFlutterBinding.ensureInitialized();
setWindowTitle('Provider Demo');
setWindowMinSize(const Size(windowWidth, windowHeight));
@@ -46,12 +47,18 @@ GoRouter router() {
return GoRouter(
initialLocation: '/login',
routes: [
GoRoute(path: '/login', builder: (context, state) => const MyLogin()),
GoRoute(
path: '/login',
builder: (context, state) => const MyLogin(),
),
GoRoute(
path: '/catalog',
builder: (context, state) => const MyCatalog(),
routes: [
GoRoute(path: 'cart', builder: (context, state) => const MyCart()),
GoRoute(
path: 'cart',
builder: (context, state) => const MyCart(),
),
],
),
],

View File

@@ -24,7 +24,8 @@ class CartModel extends ChangeNotifier {
}
/// List of items in the cart.
List<Item> get items => _itemIds.map((id) => _catalog.getById(id)).toList();
List<Item> get items =>
_itemIds.map((id) => _catalog.getById(id)).toList();
/// The current total price of all items.
int get totalPrice =>

View File

@@ -13,7 +13,10 @@ class MyCart extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Cart', style: Theme.of(context).textTheme.displayLarge),
title: Text(
'Cart',
style: Theme.of(context).textTheme.displayLarge,
),
backgroundColor: Colors.white,
),
body: Container(
@@ -46,17 +49,16 @@ class _CartList extends StatelessWidget {
return ListView.builder(
itemCount: cart.items.length,
itemBuilder:
(context, index) => ListTile(
leading: const Icon(Icons.done),
trailing: IconButton(
icon: const Icon(Icons.remove_circle_outline),
onPressed: () {
cart.remove(cart.items[index]);
},
),
title: Text(cart.items[index].name, style: itemNameStyle),
),
itemBuilder: (context, index) => ListTile(
leading: const Icon(Icons.done),
trailing: IconButton(
icon: const Icon(Icons.remove_circle_outline),
onPressed: () {
cart.remove(cart.items[index]);
},
),
title: Text(cart.items[index].name, style: itemNameStyle),
),
);
}
}
@@ -81,15 +83,16 @@ class _CartTotal extends StatelessWidget {
// The important thing is that it will not rebuild
// the rest of the widgets in this build method.
Consumer<CartModel>(
builder:
(context, cart, child) =>
Text('\$${cart.totalPrice}', style: hugeStyle),
builder: (context, cart, child) =>
Text('\$${cart.totalPrice}', style: hugeStyle),
),
const SizedBox(width: 24),
FilledButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Buying not supported yet.')),
const SnackBar(
content: Text('Buying not supported yet.'),
),
);
},
style: TextButton.styleFrom(foregroundColor: Colors.white),

View File

@@ -48,17 +48,16 @@ class _AddButton extends StatelessWidget {
);
return TextButton(
onPressed:
isInCart
? null
: () {
// If the item is not in cart, we let the user add it.
// We are using context.read() here because the callback
// is executed whenever the user taps the button. In other
// words, it is executed outside the build method.
var cart = context.read<CartModel>();
cart.add(item);
},
onPressed: isInCart
? null
: () {
// If the item is not in cart, we let the user add it.
// We are using context.read() here because the callback
// is executed whenever the user taps the button. In other
// words, it is executed outside the build method.
var cart = context.read<CartModel>();
cart.add(item);
},
style: ButtonStyle(
overlayColor: WidgetStateProperty.resolveWith<Color?>((states) {
if (states.contains(WidgetState.pressed)) {
@@ -67,10 +66,9 @@ class _AddButton extends StatelessWidget {
return null; // Defer to the widget's default.
}),
),
child:
isInCart
? const Icon(Icons.check, semanticLabel: 'ADDED')
: const Text('ADD'),
child: isInCart
? const Icon(Icons.check, semanticLabel: 'ADDED')
: const Text('ADD'),
);
}
}
@@ -79,7 +77,10 @@ class _MyAppBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SliverAppBar(
title: Text('Catalog', style: Theme.of(context).textTheme.displayLarge),
title: Text(
'Catalog',
style: Theme.of(context).textTheme.displayLarge,
),
floating: true,
actions: [
IconButton(
@@ -111,7 +112,10 @@ class _MyListItem extends StatelessWidget {
maxHeight: 48,
child: Row(
children: [
AspectRatio(aspectRatio: 1, child: Container(color: item.color)),
AspectRatio(
aspectRatio: 1,
child: Container(color: item.color),
),
const SizedBox(width: 24),
Expanded(child: Text(item.name, style: textTheme)),
const SizedBox(width: 24),

View File

@@ -17,7 +17,10 @@ class MyLogin extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Welcome', style: Theme.of(context).textTheme.displayLarge),
Text(
'Welcome',
style: Theme.of(context).textTheme.displayLarge,
),
TextFormField(
decoration: const InputDecoration(hintText: 'Username'),
),
@@ -30,7 +33,9 @@ class MyLogin extends StatelessWidget {
onPressed: () {
context.pushReplacement('/catalog');
},
style: ElevatedButton.styleFrom(backgroundColor: Colors.yellow),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.yellow,
),
child: const Text('ENTER'),
),
],

View File

@@ -1,16 +1,16 @@
name: provider_shopper
description: A shopping app sample that uses Provider for state management.
publish_to: none
version: 1.0.0+1
resolution: workspace
environment:
sdk: ^3.7.0-0
sdk: ^3.9.0-0
dependencies:
flutter:
sdk: flutter
go_router: ^16.1.0
go_router: ^16.0.0
provider: ^6.0.2
window_size:
git:
@@ -22,7 +22,6 @@ dev_dependencies:
path: ../analysis_defaults
flutter_test:
sdk: flutter
flutter:
uses-material-design: true