From cc58d26d7c39df25ea8f5302df26ad103672f6a7 Mon Sep 17 00:00:00 2001 From: tairoroberto Date: Fri, 2 May 2025 08:56:59 -0300 Subject: [PATCH] fix: update Deep Link query parameters and add tests --- flutter_modular/CHANGELOG.md | 3 +++ .../modular_route_information_parser.dart | 5 ++++- flutter_modular/pubspec.yaml | 2 +- ...modular_route_information_parser_test.dart | 21 +++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/flutter_modular/CHANGELOG.md b/flutter_modular/CHANGELOG.md index 241a9523..990a9837 100644 --- a/flutter_modular/CHANGELOG.md +++ b/flutter_modular/CHANGELOG.md @@ -1,3 +1,6 @@ +## [6.3.4] - 2025-05-02 +- Fix Deep Link query parameters + ## [6.3.3] - 2024-04-08 - Fix Deep Link diff --git a/flutter_modular/lib/src/presenter/navigation/modular_route_information_parser.dart b/flutter_modular/lib/src/presenter/navigation/modular_route_information_parser.dart index 3300095e..be42b1da 100644 --- a/flutter_modular/lib/src/presenter/navigation/modular_route_information_parser.dart +++ b/flutter_modular/lib/src/presenter/navigation/modular_route_information_parser.dart @@ -47,7 +47,10 @@ class ModularRouteInformationParser path = location; } - return selectBook(path); + return selectBook( + path, + arguments: routeInformation.uri.queryParameters, + ); } @override diff --git a/flutter_modular/pubspec.yaml b/flutter_modular/pubspec.yaml index e6e642a1..97a14302 100644 --- a/flutter_modular/pubspec.yaml +++ b/flutter_modular/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_modular description: Smart project structure with dependency injection and route management -version: 6.3.3 +version: 6.3.4 homepage: https://github.com/Flutterando/modular environment: diff --git a/flutter_modular/test/src/presenter/navigation/modular_route_information_parser_test.dart b/flutter_modular/test/src/presenter/navigation/modular_route_information_parser_test.dart index ef7298fe..eec4bdee 100644 --- a/flutter_modular/test/src/presenter/navigation/modular_route_information_parser_test.dart +++ b/flutter_modular/test/src/presenter/navigation/modular_route_information_parser_test.dart @@ -81,6 +81,27 @@ void main() { expect(book.chapters().first.name, '/'); }); + test('parseRouteInformation calls selectBook with correct arguments', + () async { + final routeMock = ParallelRouteMock(); + final params = {'param': 'value'}; + final uri = Uri.parse('/test'); + when(() => routeMock.uri).thenReturn(uri); + when(() => routeMock.parent).thenReturn(''); + when(() => routeMock.middlewares).thenReturn([]); + when(() => getRoute.call(any())) + .thenAnswer((_) async => Success(routeMock)); + when(() => getArguments.call()) + .thenReturn(Success(ModularArguments(uri: uri, data: params))); + when(() => reportPush(routeMock)).thenReturn(const Success(unit)); + + const routeInformation = RouteInformation(location: '/test?param=value'); + final book = await parser.parseRouteInformation(routeInformation); + + expect(book.uri.toString(), '/test'); + expect(parser.getArguments.call().getOrNull()?.data, params); + }); + test('selectBook with parents', () async { final routeMock = ParallelRouteMock(); when(() => routeMock.uri).thenReturn(Uri.parse('/test'));