Skip to content

Commit 1dfd957

Browse files
committed
nav [nfc]: Use a buildRoute pattern for MessageListPage
This lets the widget class better encapsulate what its route is meant to look like. That will help us as we start to do slightly more complex things with the routes.
1 parent 83cd4cc commit 1dfd957

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/widgets/app.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ class HomePage extends StatelessWidget {
7171
const SizedBox(height: 16),
7272
ElevatedButton(
7373
onPressed: () => Navigator.push(context,
74-
MaterialAccountPageRoute(context: context, builder: (context) =>
75-
const MessageListPage())),
74+
MessageListPage.buildRoute(context)),
7675
child: const Text("All messages")),
7776
])));
7877
}
@@ -81,6 +80,11 @@ class HomePage extends StatelessWidget {
8180
class MessageListPage extends StatelessWidget {
8281
const MessageListPage({super.key});
8382

83+
static Route<void> buildRoute(BuildContext context) {
84+
return MaterialAccountPageRoute(context: context,
85+
builder: (context) => const MessageListPage());
86+
}
87+
8488
@override
8589
Widget build(BuildContext context) {
8690
return Scaffold(

0 commit comments

Comments
 (0)