From 2eaec6aca3b246e10741c1215a2fe4f63671d0d0 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Thu, 6 Apr 2023 01:12:00 +0200 Subject: [PATCH 01/10] - fixed return value of the push method --- packages/go_router_builder/lib/src/route_config.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/go_router_builder/lib/src/route_config.dart b/packages/go_router_builder/lib/src/route_config.dart index 9d7c1d97b160..d4ad1dbe8deb 100644 --- a/packages/go_router_builder/lib/src/route_config.dart +++ b/packages/go_router_builder/lib/src/route_config.dart @@ -207,8 +207,8 @@ extension $_extensionName on $_className { void go(BuildContext context) => context.go(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); - void push(BuildContext context) => - context.push(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); + Future push(BuildContext context) => + context.push(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); void pushReplacement(BuildContext context) => context.pushReplacement(location${_extraParam != null ? ', extra: $extraFieldName' : ''}); From a88a038ef1667b7cdbd9680d44e5615bd6891916 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Fri, 7 Apr 2023 12:15:22 +0200 Subject: [PATCH 02/10] - updated all corresponding files so that test can pass --- .../example/lib/all_types.g.dart | 26 +++++++++---------- .../go_router_builder/example/lib/main.g.dart | 11 ++++---- .../example/lib/shell_route_example.g.dart | 6 ++--- .../lib/shell_route_with_keys_example.g.dart | 6 ++--- .../example/lib/simple_example.g.dart | 4 +-- .../_go_router_builder_test_input.dart | 11 ++++---- 6 files changed, 33 insertions(+), 31 deletions(-) diff --git a/packages/go_router_builder/example/lib/all_types.g.dart b/packages/go_router_builder/example/lib/all_types.g.dart index 0dc37d5e5339..7cf692f6cbe7 100644 --- a/packages/go_router_builder/example/lib/all_types.g.dart +++ b/packages/go_router_builder/example/lib/all_types.g.dart @@ -81,7 +81,7 @@ extension $AllTypesBaseRouteExtension on AllTypesBaseRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -103,7 +103,7 @@ extension $BigIntRouteExtension on BigIntRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -133,7 +133,7 @@ extension $BoolRouteExtension on BoolRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -157,7 +157,7 @@ extension $DateTimeRouteExtension on DateTimeRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -187,7 +187,7 @@ extension $DoubleRouteExtension on DoubleRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -213,7 +213,7 @@ extension $IntRouteExtension on IntRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -239,7 +239,7 @@ extension $NumRouteExtension on NumRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -271,7 +271,7 @@ extension $EnumRouteExtension on EnumRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -303,7 +303,7 @@ extension $EnhancedEnumRouteExtension on EnhancedEnumRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -329,7 +329,7 @@ extension $StringRouteExtension on StringRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -350,7 +350,7 @@ extension $UriRouteExtension on UriRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -466,7 +466,7 @@ extension $IterableRouteExtension on IterableRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -580,7 +580,7 @@ extension $IterableRouteWithDefaultValuesExtension void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); diff --git a/packages/go_router_builder/example/lib/main.g.dart b/packages/go_router_builder/example/lib/main.g.dart index ba15ccd83f7b..588a9058d295 100644 --- a/packages/go_router_builder/example/lib/main.g.dart +++ b/packages/go_router_builder/example/lib/main.g.dart @@ -45,7 +45,7 @@ extension $HomeRouteExtension on HomeRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -62,7 +62,7 @@ extension $FamilyRouteExtension on FamilyRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -80,7 +80,7 @@ extension $PersonRouteExtension on PersonRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -101,7 +101,8 @@ extension $PersonDetailsRouteExtension on PersonDetailsRoute { void go(BuildContext context) => context.go(location, extra: $extra); - void push(BuildContext context) => context.push(location, extra: $extra); + Future push(BuildContext context) => + context.push(location, extra: $extra); void pushReplacement(BuildContext context) => context.pushReplacement(location, extra: $extra); @@ -137,7 +138,7 @@ extension $LoginRouteExtension on LoginRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); diff --git a/packages/go_router_builder/example/lib/shell_route_example.g.dart b/packages/go_router_builder/example/lib/shell_route_example.g.dart index 531502515a05..e3544c7320ff 100644 --- a/packages/go_router_builder/example/lib/shell_route_example.g.dart +++ b/packages/go_router_builder/example/lib/shell_route_example.g.dart @@ -27,7 +27,7 @@ extension $LoginRouteExtension on LoginRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -61,7 +61,7 @@ extension $FooRouteDataExtension on FooRouteData { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -76,7 +76,7 @@ extension $BarRouteDataExtension on BarRouteData { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); diff --git a/packages/go_router_builder/example/lib/shell_route_with_keys_example.g.dart b/packages/go_router_builder/example/lib/shell_route_with_keys_example.g.dart index 523af4e98935..a8a51017e33b 100644 --- a/packages/go_router_builder/example/lib/shell_route_with_keys_example.g.dart +++ b/packages/go_router_builder/example/lib/shell_route_with_keys_example.g.dart @@ -48,7 +48,7 @@ extension $HomeRouteDataExtension on HomeRouteData { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -64,7 +64,7 @@ extension $UsersRouteDataExtension on UsersRouteData { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -81,7 +81,7 @@ extension $UserRouteDataExtension on UserRouteData { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); diff --git a/packages/go_router_builder/example/lib/simple_example.g.dart b/packages/go_router_builder/example/lib/simple_example.g.dart index 4edd92ae6e1d..16538ef16225 100644 --- a/packages/go_router_builder/example/lib/simple_example.g.dart +++ b/packages/go_router_builder/example/lib/simple_example.g.dart @@ -32,7 +32,7 @@ extension $HomeRouteExtension on HomeRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -49,7 +49,7 @@ extension $FamilyRouteExtension on FamilyRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); diff --git a/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart b/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart index 2b843c1e8d72..987d0776327b 100644 --- a/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart +++ b/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart @@ -88,7 +88,7 @@ extension $EnumParamExtension on EnumParam { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -140,7 +140,7 @@ extension $DefaultValueRouteExtension on DefaultValueRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -182,7 +182,8 @@ extension $ExtraValueRouteExtension on ExtraValueRoute { void go(BuildContext context) => context.go(location, extra: $extra); - void push(BuildContext context) => context.push(location, extra: $extra); + Future push(BuildContext context) => + context.push(location, extra: $extra); void pushReplacement(BuildContext context) => context.pushReplacement(location, extra: $extra); @@ -238,7 +239,7 @@ extension $IterableWithEnumRouteExtension on IterableWithEnumRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); @@ -291,7 +292,7 @@ extension $IterableDefaultValueRouteExtension on IterableDefaultValueRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); From 00f21abf0ac8c23ce793cb85f985595b82d6c086 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Fri, 7 Apr 2023 12:19:03 +0200 Subject: [PATCH 03/10] - bumped the version and updated the CHANGELOG accordingly --- packages/go_router_builder/CHANGELOG.md | 6 +++++- packages/go_router_builder/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index 3fcea0b2dc63..ee75ffbf24d7 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,4 +1,8 @@ -## 1.2.0 +## 1.2.1 + +* Generated routes now adhere to the updated `push` method by having the ability to return the value. [go_router CHANGELOG](https://github.com/flutter/packages/blob/main/packages/go_router/CHANGELOG.md#650) + +* ## 1.2.0 * Adds Support for ShellRoute diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml index 99d3ba34f5db..fe1af19562bd 100644 --- a/packages/go_router_builder/pubspec.yaml +++ b/packages/go_router_builder/pubspec.yaml @@ -2,7 +2,7 @@ name: go_router_builder description: >- A builder that supports generated strongly-typed route helpers for package:go_router -version: 1.2.0 +version: 1.2.1 repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22 From 866fd0771dc6b13e7b92995b3e48c2895db0cf46 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Fri, 7 Apr 2023 13:25:19 +0200 Subject: [PATCH 04/10] - added new example UI for the return value --- packages/go_router_builder/README.md | 11 +++ .../go_router_builder/example/lib/main.dart | 81 ++++++++++++++++--- .../go_router_builder/example/lib/main.g.dart | 21 +++++ 3 files changed, 104 insertions(+), 9 deletions(-) diff --git a/packages/go_router_builder/README.md b/packages/go_router_builder/README.md index e911d33be5c4..6632625afc8d 100644 --- a/packages/go_router_builder/README.md +++ b/packages/go_router_builder/README.md @@ -165,6 +165,17 @@ void _tap() => PersonRoute(pid: 'p1').go(context); This is the point of typed routing: the error is found statically. +## Return value + +Starting from `go_router` 6.5.0, pushing a route and subsequently popping it, can produce +a return value. The generated routes also follow this functionality. + +```dart +void _tap() async { + final result = await PersonRoute(pid: 'p1').go(context); +} +``` + ## Query parameters Optional parameters (named or positional) indicate query parameters: diff --git a/packages/go_router_builder/example/lib/main.dart b/packages/go_router_builder/example/lib/main.dart index f6a64edf1842..9be2a077d6ef 100644 --- a/packages/go_router_builder/example/lib/main.dart +++ b/packages/go_router_builder/example/lib/main.dart @@ -76,7 +76,8 @@ class App extends StatelessWidget { ], ), ], - ) + ), + TypedGoRoute(path: 'family-count/:count'), ], ) class HomeRoute extends GoRouteData { @@ -149,6 +150,17 @@ class PersonDetailsRoute extends GoRouteData { } } +class FamilyCountRoute extends GoRouteData { + const FamilyCountRoute(this.count); + + final int count; + + @override + Widget build(BuildContext context, GoRouterState state) => FamilyCountScreen( + count: count, + ); +} + class HomeScreen extends StatelessWidget { const HomeScreen({super.key}); @@ -161,14 +173,36 @@ class HomeScreen extends StatelessWidget { title: const Text(App.title), centerTitle: true, actions: [ - ElevatedButton( - onPressed: () => const PersonRoute('f1', 1).push(context), - child: const Text('Push a route'), - ), - IconButton( - onPressed: info.logout, - tooltip: 'Logout: ${info.userName}', - icon: const Icon(Icons.logout), + PopupMenuButton( + itemBuilder: (BuildContext context) { + return >[ + PopupMenuItem( + value: '1', + child: const Text('Push w/o return value'), + onTap: () => PersonRoute('f1', 1).push(context), + ), + PopupMenuItem( + value: '2', + child: const Text('Push w/ return value'), + onTap: () async { + final result = + await FamilyCountRoute(familyData.length).push(context); + + if (result == null) return; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Age was: $result'), + ), + ); + }, + ), + PopupMenuItem( + value: '3', + child: Text('Logout: ${info.userName}'), + onTap: () => info.logout(), + ), + ]; + }, ), ], ), @@ -277,6 +311,35 @@ class PersonDetailsPage extends StatelessWidget { ); } +class FamilyCountScreen extends StatelessWidget { + const FamilyCountScreen({super.key, required this.count}); + + final int count; + + @override + Widget build(BuildContext context) => Scaffold( + appBar: AppBar(title: const Text('Family Count')), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Center( + child: Text( + 'There are $count families', + style: Theme.of(context).textTheme.headline5, + ), + ), + ElevatedButton( + onPressed: () => context.pop(count), + child: Text('Pop with return value $count'), + ), + ], + ), + ), + ); +} + class LoginScreen extends StatelessWidget { const LoginScreen({this.from, super.key}); final String? from; diff --git a/packages/go_router_builder/example/lib/main.g.dart b/packages/go_router_builder/example/lib/main.g.dart index 588a9058d295..864e8e121ef8 100644 --- a/packages/go_router_builder/example/lib/main.g.dart +++ b/packages/go_router_builder/example/lib/main.g.dart @@ -33,6 +33,10 @@ RouteBase get $homeRoute => GoRouteData.$route( ), ], ), + GoRouteData.$route( + path: 'family-count/:count', + factory: $FamilyCountRouteExtension._fromState, + ), ], ); @@ -108,6 +112,23 @@ extension $PersonDetailsRouteExtension on PersonDetailsRoute { context.pushReplacement(location, extra: $extra); } +extension $FamilyCountRouteExtension on FamilyCountRoute { + static FamilyCountRoute _fromState(GoRouterState state) => FamilyCountRoute( + int.parse(state.params['count']!), + ); + + String get location => GoRouteData.$location( + '/family-count/${Uri.encodeComponent(count.toString())}', + ); + + void go(BuildContext context) => context.go(location); + + Future push(BuildContext context) => context.push(location); + + void pushReplacement(BuildContext context) => + context.pushReplacement(location); +} + const _$PersonDetailsEnumMap = { PersonDetails.hobbies: 'hobbies', PersonDetails.favoriteFood: 'favorite-food', From b95a06ed7484e9595a0f28217c8f040c0bc17a31 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Fri, 7 Apr 2023 13:25:31 +0200 Subject: [PATCH 05/10] - updated the example tests --- .../example/test/widget_test.dart | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/go_router_builder/example/test/widget_test.dart b/packages/go_router_builder/example/test/widget_test.dart index aa6061a42b49..4433d664ef3c 100644 --- a/packages/go_router_builder/example/test/widget_test.dart +++ b/packages/go_router_builder/example/test/widget_test.dart @@ -2,6 +2,7 @@ // 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/main.dart'; @@ -12,13 +13,24 @@ void main() { await tester.tap(find.text('Login')); await tester.pumpAndSettle(); - await tester.tap(find.text('Push a route')); + await _openPopupMenu(tester); + + await tester.tap(find.text('Push w/o return value')); await tester.pumpAndSettle(); expect(find.text('Chris'), findsOneWidget); await tester.pageBack(); await tester.pumpAndSettle(); + await _openPopupMenu(tester); + + await tester.tap(find.text('Push w/ return value')); + await tester.pumpAndSettle(); + expect(find.text('Family Count'), findsOneWidget); + + await tester.pageBack(); + await tester.pumpAndSettle(); + await tester.tap(find.text('Sells')); await tester.pumpAndSettle(); @@ -39,3 +51,11 @@ void main() { expect(find.text('Extra click count: 1'), findsOneWidget); }); } + +Future _openPopupMenu(WidgetTester tester) async { + final moreButton = find.byIcon(Icons.more_vert); + expect(moreButton, findsOneWidget); + + await tester.tap(moreButton); + await tester.pumpAndSettle(); +} From 6295a66f972d8bed6a414901f54abf1ff3ee2242 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Fri, 7 Apr 2023 13:35:23 +0200 Subject: [PATCH 06/10] - resolved analyzer warnings --- .../go_router_builder/example/lib/main.dart | 26 ++++++++++--------- .../example/test/widget_test.dart | 4 +-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/go_router_builder/example/lib/main.dart b/packages/go_router_builder/example/lib/main.dart index 9be2a077d6ef..579c43188f70 100644 --- a/packages/go_router_builder/example/lib/main.dart +++ b/packages/go_router_builder/example/lib/main.dart @@ -173,27 +173,29 @@ class HomeScreen extends StatelessWidget { title: const Text(App.title), centerTitle: true, actions: [ - PopupMenuButton( + PopupMenuButton( itemBuilder: (BuildContext context) { return >[ PopupMenuItem( value: '1', child: const Text('Push w/o return value'), - onTap: () => PersonRoute('f1', 1).push(context), + onTap: () => const PersonRoute('f1', 1).push(context), ), PopupMenuItem( value: '2', child: const Text('Push w/ return value'), onTap: () async { - final result = - await FamilyCountRoute(familyData.length).push(context); - - if (result == null) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Age was: $result'), - ), - ); + FamilyCountRoute(familyData.length) + .push(context) + .then((int? value) { + if (value != null) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Age was: $value'), + ), + ); + } + }); }, ), PopupMenuItem( @@ -323,7 +325,7 @@ class FamilyCountScreen extends StatelessWidget { padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ + children: [ Center( child: Text( 'There are $count families', diff --git a/packages/go_router_builder/example/test/widget_test.dart b/packages/go_router_builder/example/test/widget_test.dart index 4433d664ef3c..e53f9123c763 100644 --- a/packages/go_router_builder/example/test/widget_test.dart +++ b/packages/go_router_builder/example/test/widget_test.dart @@ -52,8 +52,8 @@ void main() { }); } -Future _openPopupMenu(WidgetTester tester) async { - final moreButton = find.byIcon(Icons.more_vert); +Future _openPopupMenu(WidgetTester tester) async { + final Finder moreButton = find.byIcon(Icons.more_vert); expect(moreButton, findsOneWidget); await tester.tap(moreButton); From 828127a5b1a97301a150e9a01c377797646c492b Mon Sep 17 00:00:00 2001 From: MicheleBenedetti <45004856+Michele-x98@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:57:21 +0200 Subject: [PATCH 07/10] Update main.dart --- packages/go_router_builder/example/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/go_router_builder/example/lib/main.dart b/packages/go_router_builder/example/lib/main.dart index 579c43188f70..cf917c59b5ce 100644 --- a/packages/go_router_builder/example/lib/main.dart +++ b/packages/go_router_builder/example/lib/main.dart @@ -329,7 +329,7 @@ class FamilyCountScreen extends StatelessWidget { Center( child: Text( 'There are $count families', - style: Theme.of(context).textTheme.headline5, + style: Theme.of(context).textTheme.headlineSmall, ), ), ElevatedButton( From 8bce211f9ccf0f1425d1ed4ba64ef024d739cdd8 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Thu, 13 Apr 2023 09:36:46 +0200 Subject: [PATCH 08/10] - resolved merge conflicts and updated the version --- packages/go_router_builder/CHANGELOG.md | 4 ++++ packages/go_router_builder/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index da0e1f2cd935..b7cfba382c50 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.2 + +* Generated routes now adhere to the updated `push` method by having the ability to return the value. [go_router CHANGELOG](https://github.com/flutter/packages/blob/main/packages/go_router/CHANGELOG.md#650) + ## 1.2.1 * Supports opt-in required extra parameters. [#117261](https://github.com/flutter/flutter/issues/117261) diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml index fe1af19562bd..11726b6ebcc7 100644 --- a/packages/go_router_builder/pubspec.yaml +++ b/packages/go_router_builder/pubspec.yaml @@ -2,7 +2,7 @@ name: go_router_builder description: >- A builder that supports generated strongly-typed route helpers for package:go_router -version: 1.2.1 +version: 1.2.2 repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22 From eeb86a984c853faeb9099ca5d27349c6e1c3de36 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Thu, 13 Apr 2023 09:54:20 +0200 Subject: [PATCH 09/10] - fixed failing tests --- .../go_router_builder/example/lib/extra_example.g.dart | 8 +++++--- .../test/test_inputs/_go_router_builder_test_input.dart | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/go_router_builder/example/lib/extra_example.g.dart b/packages/go_router_builder/example/lib/extra_example.g.dart index b9febb44e7a7..1a090c3a42b3 100644 --- a/packages/go_router_builder/example/lib/extra_example.g.dart +++ b/packages/go_router_builder/example/lib/extra_example.g.dart @@ -31,7 +31,8 @@ extension $RequiredExtraRouteExtension on RequiredExtraRoute { void go(BuildContext context) => context.go(location, extra: $extra); - void push(BuildContext context) => context.push(location, extra: $extra); + Future push(BuildContext context) => + context.push(location, extra: $extra); void pushReplacement(BuildContext context) => context.pushReplacement(location, extra: $extra); @@ -54,7 +55,8 @@ extension $OptionalExtraRouteExtension on OptionalExtraRoute { void go(BuildContext context) => context.go(location, extra: $extra); - void push(BuildContext context) => context.push(location, extra: $extra); + Future push(BuildContext context) => + context.push(location, extra: $extra); void pushReplacement(BuildContext context) => context.pushReplacement(location, extra: $extra); @@ -74,7 +76,7 @@ extension $SplashRouteExtension on SplashRoute { void go(BuildContext context) => context.go(location); - void push(BuildContext context) => context.push(location); + Future push(BuildContext context) => context.push(location); void pushReplacement(BuildContext context) => context.pushReplacement(location); diff --git a/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart b/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart index 5d2b63ea1a1d..1e39c205ef6c 100644 --- a/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart +++ b/packages/go_router_builder/test/test_inputs/_go_router_builder_test_input.dart @@ -214,7 +214,8 @@ extension $RequiredExtraValueRouteExtension on RequiredExtraValueRoute { void go(BuildContext context) => context.go(location, extra: $extra); - void push(BuildContext context) => context.push(location, extra: $extra); + Future push(BuildContext context) => + context.push(location, extra: $extra); void pushReplacement(BuildContext context) => context.pushReplacement(location, extra: $extra); From 02b7edbacba28e97e6067fea9e034ebce867eb23 Mon Sep 17 00:00:00 2001 From: Vladimir Zdravkovic Date: Fri, 21 Apr 2023 10:44:29 +0200 Subject: [PATCH 10/10] Updated CHANGELOG.md per PR review comments --- packages/go_router_builder/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index b7cfba382c50..a7414a840e50 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,6 +1,6 @@ ## 1.2.2 -* Generated routes now adhere to the updated `push` method by having the ability to return the value. [go_router CHANGELOG](https://github.com/flutter/packages/blob/main/packages/go_router/CHANGELOG.md#650) +* Supports returning value in generated `push` method. [go_router CHANGELOG](https://github.com/flutter/packages/blob/main/packages/go_router/CHANGELOG.md#650) ## 1.2.1