forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[go_router] [shell_route] Add observers parameter (flutter#2664)
* [go_router] [shell_route] Add observers parameter * [go_router] [shell_route] Add observers parameter test * Added Licence for shell_route_observers_test.dart * [go_router] [shell_route] Added type annotation to shell_route_observers_test.dart * [go_router] [shell_route] Use `HeroControllerScope` for nested Navigator * Use the correct HeroController based on the App type. * Cache the HeroController for the nested Navigator. * Clean up previous cache to prevent memory leak. * Added better cache-clearing policy for the HeroController cache. * Fixed Typos Co-authored-by: chunhtai <[email protected]> * Fixed Typos Co-authored-by: chunhtai <[email protected]> * [go_router] [shell_route] Added a better Hero test Credits to @flodaniel! --------- Co-authored-by: chunhtai <[email protected]>
- Loading branch information
Showing
8 changed files
with
133 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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/go_router.dart'; | ||
|
||
void main() { | ||
test('ShellRoute observers test', () { | ||
final ShellRoute shell = ShellRoute( | ||
observers: <NavigatorObserver>[HeroController()], | ||
builder: (BuildContext context, GoRouterState state, Widget child) { | ||
return SafeArea(child: child); | ||
}, | ||
routes: <RouteBase>[ | ||
GoRoute( | ||
path: '/home', | ||
builder: (BuildContext context, GoRouterState state) { | ||
return Container(); | ||
}, | ||
), | ||
], | ||
); | ||
|
||
expect(shell.observers!.length, 1); | ||
}); | ||
} |