From 8c448e32fc2ff842e8b69f0b9bcb1457d754687e Mon Sep 17 00:00:00 2001 From: Emerson Almeida Date: Sat, 22 Jun 2024 12:58:24 -0300 Subject: [PATCH] try flutter versions --- .github/workflows/dart.yml | 7 +++++-- example/better_router_example.dart | 10 +++++----- pubspec.yaml | 5 ++--- test/better_router_test.dart | 26 +++++++++++++------------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index d3bb5cc..ea65856 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -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 }} @@ -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: @@ -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 diff --git a/example/better_router_example.dart b/example/better_router_example.dart index ba2648c..e1af62e 100644 --- a/example/better_router_example.dart +++ b/example/better_router_example.dart @@ -15,21 +15,21 @@ final routes = 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\/(?.+)": 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"), @@ -44,13 +44,13 @@ final routes = 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 = [ diff --git a/pubspec.yaml b/pubspec.yaml index e143b44..09059a0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 diff --git a/test/better_router_test.dart b/test/better_router_test.dart index 9d2e08b..875d145 100644 --- a/test/better_router_test.dart +++ b/test/better_router_test.dart @@ -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\/(?.+)": 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"), @@ -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); @@ -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); @@ -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); @@ -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]; @@ -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"); @@ -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);