mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
This PR is an extension of the previous PR #4300 that I submitted. The previous PR, being based on the main branch, was closed and the contents were copied to a new branch in order to make further contributions.ð In the previous PR, an assertion error was fixed by adding `routeInformationProvider` to `MaterialApp.router`. After a series of code reviews, we updated to use routerConfig and added some test codes. All the contents have been transferred to the current `bugfix/RouterConfig` branch. --- *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This commit is contained in:
@ -550,9 +550,7 @@ class AllTypesApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => MaterialApp.router(
|
Widget build(BuildContext context) => MaterialApp.router(
|
||||||
routeInformationParser: _router.routeInformationParser,
|
routerConfig: _router,
|
||||||
routerDelegate: _router.routerDelegate,
|
|
||||||
routeInformationProvider: _router.routeInformationProvider,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
late final GoRouter _router = GoRouter(
|
late final GoRouter _router = GoRouter(
|
||||||
|
@ -26,9 +26,7 @@ class App extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) => ChangeNotifierProvider<LoginInfo>.value(
|
Widget build(BuildContext context) => ChangeNotifierProvider<LoginInfo>.value(
|
||||||
value: loginInfo,
|
value: loginInfo,
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
routeInformationParser: _router.routeInformationParser,
|
routerConfig: _router,
|
||||||
routerDelegate: _router.routerDelegate,
|
|
||||||
routeInformationProvider: _router.routeInformationProvider,
|
|
||||||
title: title,
|
title: title,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
),
|
),
|
||||||
|
@ -18,8 +18,7 @@ class App extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => MaterialApp.router(
|
Widget build(BuildContext context) => MaterialApp.router(
|
||||||
routeInformationParser: _router.routeInformationParser,
|
routerConfig: _router,
|
||||||
routerDelegate: _router.routerDelegate,
|
|
||||||
title: _appTitle,
|
title: _appTitle,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:go_router_builder_example/shared/data.dart';
|
||||||
|
import 'package:go_router_builder_example/simple_example.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('App starts on HomeScreen and displays families',
|
||||||
|
(WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(App());
|
||||||
|
expect(find.byType(HomeScreen), findsOneWidget);
|
||||||
|
expect(find.byType(ListTile), findsNWidgets(familyData.length));
|
||||||
|
for (final Family family in familyData) {
|
||||||
|
expect(find.text(family.name), findsOneWidget);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user