mirror of
https://github.com/flutter/samples.git
synced 2026-07-16 05:52:01 +00:00
Update navigation_and_routing sample to go_router (#2067)
This is a new PR to update the navigation_and_routing sample to the latest version of go_router. It is a based on https://github.com/flutter/samples/pull/1437 --------- Co-authored-by: Brett Morgan <brettmorgan@google.com>
This commit is contained in:
@@ -4,14 +4,19 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/author.dart';
|
||||
import '../data/library.dart';
|
||||
import '../routing.dart';
|
||||
import '../widgets/author_list.dart';
|
||||
|
||||
class AuthorsScreen extends StatelessWidget {
|
||||
final String title = 'Authors';
|
||||
final String title;
|
||||
final ValueChanged<Author> onTap;
|
||||
|
||||
const AuthorsScreen({super.key});
|
||||
const AuthorsScreen({
|
||||
required this.onTap,
|
||||
this.title = 'Authors',
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
@@ -20,9 +25,7 @@ class AuthorsScreen extends StatelessWidget {
|
||||
),
|
||||
body: AuthorList(
|
||||
authors: libraryInstance.allAuthors,
|
||||
onTap: (author) {
|
||||
RouteStateScope.of(context).go('/author/${author.id}');
|
||||
},
|
||||
onTap: onTap,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user