Skip to content

Commit

Permalink
try flutter versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dukex committed Jun 22, 2024
1 parent 8295480 commit eb4a9ff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Generate matrix from pubspec.yaml
uses: flutter-actions/pubspec-matrix-action@v1
with:
pubspec: "pubspec.yaml"
channel: "stable"
outputs:
matrix: ${{ steps.pubspec.outputs.matrix }}

Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: flutter-actions/setup-flutter@v3
with:
Expand All @@ -36,6 +36,9 @@ jobs:

- run: flutter --version

- run: dart pub add lints
- run: dart pub add test

- name: Install dependencies
run: flutter pub get

Expand Down
10 changes: 5 additions & 5 deletions example/better_router_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ final routes = <String, PageRoute<dynamic> Function(RouteSettings)>{
onPressed: () =>
Navigator.pushNamed(context, "/custom_route_transition"),
child: Text("Go to custom transition"))
])),
])).call,
'/books': DefaultPageRouteBuilder((context) => Column(children: [
for (var i = 0; i < books.length; i++)
TextButton(
onPressed: () =>
Navigator.pushNamed(context, "/books/${books[i].id}"),
child: Text(books[i].name))
])),
])).call,
r"\/books\/(?<id>.+)": DefaultPageRouteBuilder((context) {
final params = RouteParams.of(context);

return Column(
children: [Text('book page'), Text("Book ID: ${params['id']}")],
);
}),
}).call,
'/custom_route_transition': (RouteSettings settings) => PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) =>
Text("Transition"),
Expand All @@ -44,13 +44,13 @@ final routes = <String, PageRoute<dynamic> Function(RouteSettings)>{
child: child,
);
}),
'-matchAll': DefaultPageRouteBuilder((_) => Text('not found page')),
'-matchAll': DefaultPageRouteBuilder((_) => Text('not found page')).call,
};

void main() {
final betterRoutes = BetterRouter(routes: routes);

runApp(MaterialApp(onGenerateRoute: betterRoutes));
runApp(MaterialApp(onGenerateRoute: betterRoutes.call));
}

final books = [
Expand Down
5 changes: 2 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ description: the better router is a powerful, but for humans, flutter router.
version: 2.1.0
repository: https://github.com/dukex/better_router
environment:
sdk: '>=2.17.5 <4.0.0'
sdk: ">=2.17.5"
flutter: ">=3.0.3"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
lints: ^2.0.0
test: ^1.16.0
flutter_test:
sdk: flutter
26 changes: 13 additions & 13 deletions test/better_router_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ void main() {
onPressed: () =>
Navigator.pushNamed(context, "/custom_route_transition"),
child: Text("Custom Route"))
])),
'/home': DefaultPageRouteBuilder((_) => Text('home page')),
])).call,
'/home': DefaultPageRouteBuilder((_) => Text('home page')).call,
'/books': DefaultPageRouteBuilder((context) => Column(children: [
for (var i = 0; i < books.length; i++)
TextButton(
onPressed: () =>
Navigator.pushNamed(context, "/books/${books[i].id}"),
child: Text(books[i].name))
])),
])).call,
r"\/books\/(?<id>.+)": DefaultPageRouteBuilder((context) {
final params = RouteParams.of(context);

return Column(
children: [Text('book page'), Text("Book ID: ${params['id']}")],
);
}),
}).call,
'/custom_route_transition': (RouteSettings settings) => PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) =>
Text("Custom route page"),
Expand All @@ -51,11 +51,11 @@ void main() {
child: child,
);
}),
'-matchAll': DefaultPageRouteBuilder((_) => Text('not found page')),
'-matchAll': DefaultPageRouteBuilder((_) => Text('not found page')).call,
});

testWidgets('navigates to root page by default', (tester) async {
await tester.pumpWidget(MaterialApp(onGenerateRoute: betterRoutes));
await tester.pumpWidget(MaterialApp(onGenerateRoute: betterRoutes.call));

final textFinder = find.text("root page");
expect(textFinder, findsOneWidget);
Expand All @@ -65,7 +65,7 @@ void main() {

testWidgets('respects the initialRoute', (tester) async {
await tester.pumpWidget(
MaterialApp(initialRoute: '/home', onGenerateRoute: betterRoutes));
MaterialApp(initialRoute: '/home', onGenerateRoute: betterRoutes.call));

final textFinder = find.byType(Text);
expect(textFinder, findsOneWidget);
Expand All @@ -74,7 +74,7 @@ void main() {
});

testWidgets('navigates using Navigator', (tester) async {
await tester.pumpWidget(MaterialApp(onGenerateRoute: betterRoutes));
await tester.pumpWidget(MaterialApp(onGenerateRoute: betterRoutes.call));

final button = find.text("Books");
expect(button, findsOneWidget);
Expand All @@ -87,8 +87,8 @@ void main() {
});

testWidgets('navigates send params', (tester) async {
await tester.pumpWidget(
MaterialApp(initialRoute: '/books', onGenerateRoute: betterRoutes));
await tester.pumpWidget(MaterialApp(
initialRoute: '/books', onGenerateRoute: betterRoutes.call));

final book = books[0];

Expand All @@ -104,7 +104,7 @@ void main() {

testWidgets('navigates using custom route', (tester) async {
await tester.pumpWidget(
MaterialApp(initialRoute: '/', onGenerateRoute: betterRoutes));
MaterialApp(initialRoute: '/', onGenerateRoute: betterRoutes.call));

final buttonFinder = find.text("Custom Route");

Expand All @@ -116,8 +116,8 @@ void main() {
});

testWidgets('renders -matchAll when not found', (tester) async {
await tester.pumpWidget(
MaterialApp(initialRoute: '/not_found', onGenerateRoute: betterRoutes));
await tester.pumpWidget(MaterialApp(
initialRoute: '/not_found', onGenerateRoute: betterRoutes.call));

final textFinder = find.text("not found page");
expect(textFinder, findsOneWidget);
Expand Down

0 comments on commit eb4a9ff

Please sign in to comment.