Describe the bug
args.queryParams returning empty on children routes.
Environment
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.0, on Microsoft Windows [versÆo 10.0.22000.675], locale pt-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.7)
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3)
[✓] VS Code (version 1.66.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!
pubspec.yaml
name: router_outlet_bug
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.16.2 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_modular: ^5.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter:
uses-material-design: true
To Reproduce
Run it on Chrome and access the route directly passing a queryParam like:
http://localhost:49234/#/home?token=3123213123213
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
void main() {
return runApp(ModularApp(module: AppModule(), child: const AppWidget()));
}
class AppWidget extends StatelessWidget {
const AppWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Router Outlet Query Params',
theme: ThemeData(primarySwatch: Colors.blue),
routeInformationParser: Modular.routeInformationParser,
routerDelegate: Modular.routerDelegate,
); //added by extension
}
}
class AppModule extends Module {
@override
List<Bind> get binds => [];
@override
List<ModularRoute> get routes => [
ModuleRoute('/', module: HomeModule()),
];
}
class HomeModule extends Module {
@override
List<Bind> get binds => [];
@override
List<ModularRoute> get routes => [
ChildRoute(
'/',
child: (context, args) {
return const BasePage();
},
children: [
ChildRoute(
'/home',
child: (context, args) {
print(args.queryParams['token']); //Returns null;
print(args.queryParams); //Returns empty.
return const HomePage();
},
)
],
),
];
}
class BasePage extends StatelessWidget {
const BasePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Base Page Widget'),
),
body: const RouterOutlet(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Center(
child: Text('Home Page'),
);
}
}
Expected behavior
Expected to get the queryParams value to pass it to HomePage but the args.queryParams is empty.
Describe the bug
args.queryParams returning empty on children routes.
Environment
flutter doctor -vpubspec.yamlTo Reproduce
Run it on Chrome and access the route directly passing a queryParam like:
http://localhost:49234/#/home?token=3123213123213Expected behavior
Expected to get the queryParams value to pass it to HomePage but the
args.queryParamsis empty.