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:
@@ -19,7 +19,8 @@ const double windowWidth = 480;
|
||||
const double windowHeight = 854;
|
||||
|
||||
void setupWindow() {
|
||||
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
|
||||
if (!kIsWeb &&
|
||||
(Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
setWindowTitle('Navigation and routing');
|
||||
setWindowMinSize(const Size(windowWidth, windowHeight));
|
||||
|
||||
@@ -17,8 +17,12 @@ import 'screens/sign_in.dart';
|
||||
import 'widgets/book_list.dart';
|
||||
import 'widgets/fade_transition_page.dart';
|
||||
|
||||
final appShellNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'app shell');
|
||||
final booksNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'books shell');
|
||||
final appShellNavigatorKey = GlobalKey<NavigatorState>(
|
||||
debugLabel: 'app shell',
|
||||
);
|
||||
final booksNavigatorKey = GlobalKey<NavigatorState>(
|
||||
debugLabel: 'books shell',
|
||||
);
|
||||
|
||||
class Bookstore extends StatefulWidget {
|
||||
const Bookstore({super.key});
|
||||
|
||||
@@ -33,10 +33,9 @@ class BookstoreAuth extends ChangeNotifier {
|
||||
@override
|
||||
int get hashCode => _signedIn.hashCode;
|
||||
|
||||
static BookstoreAuth of(BuildContext context) =>
|
||||
context
|
||||
.dependOnInheritedWidgetOfExactType<BookstoreAuthScope>()!
|
||||
.notifier!;
|
||||
static BookstoreAuth of(BuildContext context) => context
|
||||
.dependOnInheritedWidgetOfExactType<BookstoreAuthScope>()!
|
||||
.notifier!;
|
||||
}
|
||||
|
||||
class BookstoreAuthScope extends InheritedNotifier<BookstoreAuth> {
|
||||
|
||||
@@ -5,32 +5,31 @@
|
||||
import 'author.dart';
|
||||
import 'book.dart';
|
||||
|
||||
final libraryInstance =
|
||||
Library()
|
||||
..addBook(
|
||||
title: 'Left Hand of Darkness',
|
||||
authorName: 'Ursula K. Le Guin',
|
||||
isPopular: true,
|
||||
isNew: true,
|
||||
)
|
||||
..addBook(
|
||||
title: 'Too Like the Lightning',
|
||||
authorName: 'Ada Palmer',
|
||||
isPopular: false,
|
||||
isNew: true,
|
||||
)
|
||||
..addBook(
|
||||
title: 'Kindred',
|
||||
authorName: 'Octavia E. Butler',
|
||||
isPopular: true,
|
||||
isNew: false,
|
||||
)
|
||||
..addBook(
|
||||
title: 'The Lathe of Heaven',
|
||||
authorName: 'Ursula K. Le Guin',
|
||||
isPopular: false,
|
||||
isNew: false,
|
||||
);
|
||||
final libraryInstance = Library()
|
||||
..addBook(
|
||||
title: 'Left Hand of Darkness',
|
||||
authorName: 'Ursula K. Le Guin',
|
||||
isPopular: true,
|
||||
isNew: true,
|
||||
)
|
||||
..addBook(
|
||||
title: 'Too Like the Lightning',
|
||||
authorName: 'Ada Palmer',
|
||||
isPopular: false,
|
||||
isNew: true,
|
||||
)
|
||||
..addBook(
|
||||
title: 'Kindred',
|
||||
authorName: 'Octavia E. Butler',
|
||||
isPopular: true,
|
||||
isNew: false,
|
||||
)
|
||||
..addBook(
|
||||
title: 'The Lathe of Heaven',
|
||||
authorName: 'Ursula K. Le Guin',
|
||||
isPopular: false,
|
||||
isNew: false,
|
||||
);
|
||||
|
||||
class Library {
|
||||
final List<Book> allBooks = [];
|
||||
@@ -60,7 +59,9 @@ class Library {
|
||||
return allBooks[int.parse(id)];
|
||||
}
|
||||
|
||||
List<Book> get popularBooks => [...allBooks.where((book) => book.isPopular)];
|
||||
List<Book> get popularBooks => [
|
||||
...allBooks.where((book) => book.isPopular),
|
||||
];
|
||||
|
||||
List<Book> get newBooks => [...allBooks.where((book) => book.isNew)];
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@ class AuthorsScreen extends StatelessWidget {
|
||||
final String title;
|
||||
final ValueChanged<Author> onTap;
|
||||
|
||||
const AuthorsScreen({required this.onTap, this.title = 'Authors', super.key});
|
||||
const AuthorsScreen({
|
||||
required this.onTap,
|
||||
this.title = 'Authors',
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
|
||||
@@ -37,26 +37,24 @@ class BookDetailsScreen extends StatelessWidget {
|
||||
onPressed: () {
|
||||
Navigator.of(context).push<void>(
|
||||
MaterialPageRoute<void>(
|
||||
builder:
|
||||
(context) => AuthorDetailsScreen(
|
||||
author: book!.author,
|
||||
onBookTapped: (book) {
|
||||
GoRouter.of(
|
||||
context,
|
||||
).go('/books/all/book/${book.id}');
|
||||
},
|
||||
),
|
||||
builder: (context) => AuthorDetailsScreen(
|
||||
author: book!.author,
|
||||
onBookTapped: (book) {
|
||||
GoRouter.of(
|
||||
context,
|
||||
).go('/books/all/book/${book.id}');
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Link(
|
||||
uri: Uri.parse('/authors/author/${book!.author.id}'),
|
||||
builder:
|
||||
(context, followLink) => TextButton(
|
||||
onPressed: followLink,
|
||||
child: const Text('View author (Link)'),
|
||||
),
|
||||
builder: (context, followLink) => TextButton(
|
||||
onPressed: followLink,
|
||||
child: const Text('View author (Link)'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -31,8 +31,14 @@ class BookstoreScaffold extends StatelessWidget {
|
||||
},
|
||||
destinations: const [
|
||||
AdaptiveScaffoldDestination(title: 'Books', icon: Icons.book),
|
||||
AdaptiveScaffoldDestination(title: 'Authors', icon: Icons.person),
|
||||
AdaptiveScaffoldDestination(title: 'Settings', icon: Icons.settings),
|
||||
AdaptiveScaffoldDestination(
|
||||
title: 'Authors',
|
||||
icon: Icons.person,
|
||||
),
|
||||
AdaptiveScaffoldDestination(
|
||||
title: 'Settings',
|
||||
icon: Icons.settings,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -26,7 +26,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
child: const Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 18, horizontal: 12),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 18,
|
||||
horizontal: 12,
|
||||
),
|
||||
child: SettingsContent(),
|
||||
),
|
||||
),
|
||||
@@ -44,7 +47,10 @@ class SettingsContent extends StatelessWidget {
|
||||
Widget build(BuildContext context) => Column(
|
||||
children: [
|
||||
...[
|
||||
Text('Settings', style: Theme.of(context).textTheme.headlineMedium),
|
||||
Text(
|
||||
'Settings',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
BookstoreAuth.of(context).signOut();
|
||||
@@ -54,11 +60,10 @@ class SettingsContent extends StatelessWidget {
|
||||
const Text('Example using the Link widget:'),
|
||||
Link(
|
||||
uri: Uri.parse('/books/all/book/0'),
|
||||
builder:
|
||||
(context, followLink) => TextButton(
|
||||
onPressed: followLink,
|
||||
child: const Text('/books/all/book/0'),
|
||||
),
|
||||
builder: (context, followLink) => TextButton(
|
||||
onPressed: followLink,
|
||||
child: const Text('/books/all/book/0'),
|
||||
),
|
||||
),
|
||||
const Text('Example using GoRouter.of(context).go():'),
|
||||
TextButton(
|
||||
@@ -70,25 +75,23 @@ class SettingsContent extends StatelessWidget {
|
||||
].map((w) => Padding(padding: const EdgeInsets.all(8), child: w)),
|
||||
const Text('Displays a dialog on the root Navigator:'),
|
||||
TextButton(
|
||||
onPressed:
|
||||
() => showDialog<String>(
|
||||
context: context,
|
||||
builder:
|
||||
(context) => AlertDialog(
|
||||
title: const Text('Alert!'),
|
||||
content: const Text('The alert description goes here.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'Cancel'),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'OK'),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
onPressed: () => showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Alert!'),
|
||||
content: const Text('The alert description goes here.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'Cancel'),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'OK'),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: const Text('Show Dialog'),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -15,11 +15,10 @@ class AuthorList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => ListView.builder(
|
||||
itemCount: authors.length,
|
||||
itemBuilder:
|
||||
(context, index) => ListTile(
|
||||
title: Text(authors[index].name),
|
||||
subtitle: Text('${authors[index].books.length} books'),
|
||||
onTap: onTap != null ? () => onTap!(authors[index]) : null,
|
||||
),
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
title: Text(authors[index].name),
|
||||
subtitle: Text('${authors[index].books.length} books'),
|
||||
onTap: onTap != null ? () => onTap!(authors[index]) : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,10 @@ class BookList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => ListView.builder(
|
||||
itemCount: books.length,
|
||||
itemBuilder:
|
||||
(context, index) => ListTile(
|
||||
title: Text(books[index].title),
|
||||
subtitle: Text(books[index].author.name),
|
||||
onTap: onTap != null ? () => onTap!(books[index]) : null,
|
||||
),
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
title: Text(books[index].title),
|
||||
subtitle: Text(books[index].author.name),
|
||||
onTap: onTap != null ? () => onTap!(books[index]) : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,17 @@ name: bookstore
|
||||
description: Navigation and routing sample app
|
||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
version: 1.0.0+1
|
||||
resolution: workspace
|
||||
|
||||
environment:
|
||||
sdk: ^3.7.0-0
|
||||
sdk: ^3.9.0-0
|
||||
|
||||
dependencies:
|
||||
adaptive_navigation: ^0.0.3
|
||||
cupertino_icons: ^1.0.2
|
||||
flutter:
|
||||
sdk: flutter
|
||||
go_router: ^16.1.0
|
||||
go_router: ^16.0.0
|
||||
url_launcher: ^6.1.1
|
||||
window_size:
|
||||
git:
|
||||
|
||||
Reference in New Issue
Block a user