-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
145 additions
and
22 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
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,57 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart' hide Route; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:tree_router/tree_router.dart'; | ||
|
||
import 'helpers.dart'; | ||
|
||
void main() { | ||
group('Redirect', () { | ||
testWidgets('redirects to a relative path at startup', | ||
(WidgetTester tester) async { | ||
final routes = <Route>[ | ||
SwitcherRoute( | ||
path: '/', | ||
builder: (_, child) => child, | ||
redirect: (match) { | ||
return SynchronousFuture('a'); | ||
}, | ||
children: [ | ||
StackedRoute( | ||
path: 'a', | ||
builder: (context) { | ||
return const AScreen(); | ||
}, | ||
), | ||
], | ||
), | ||
]; | ||
await tester.pumpWidget( | ||
TestWidget( | ||
routes: routes, | ||
initialRoute: '/', | ||
), | ||
); | ||
await tester.pumpAndSettle(); | ||
expect(find.text('Screen A'), findsOneWidget); | ||
}); | ||
}); | ||
} | ||
|
||
class HomeScreen extends StatelessWidget { | ||
const HomeScreen({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Text('Home'); | ||
} | ||
} | ||
|
||
class AScreen extends StatelessWidget { | ||
const AScreen({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Text('Screen A'); | ||
} | ||
} |