-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RouterOutlet routes persist even when parent route is popped #960
Labels
new
New issue request attention
Comments
pubspec.yaml name: modular_bug
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0
environment:
sdk: '>=3.3.3 <4.0.0'
dependencies:
flutter:
sdk: flutter
flutter_modular: ^6.3.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.0
flutter:
uses-material-design: true |
7 tasks
@zssnyder I was having the same problem, tested your solution and it worked, thanks!! dependency_overrides:
flutter_modular:
git:
url: https://github.com/zssnyder/flutter_modular.git
ref: modular_lite
path: flutter_modular
modular_core:
git:
url: https://github.com/zssnyder/flutter_modular.git
ref: modular_lite
path: modular_core |
same issue
class DemoHome extends StatelessWidget {
const DemoHome({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
ElevatedButton(
onPressed: () => Modular.to.pushNamed(Routes.s1),
child: const Text('Scrren1'),
),
ElevatedButton(
onPressed: () => Modular.to.pushNamed(Routes.s2),
child: const Text('Scrren2'),
),
],
),
);
}
}
class DemoPage extends StatelessWidget {
const DemoPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xFF162866),
foregroundColor: Colors.white,
centerTitle: true,
title: const Text('Demo Page'),
leading: const BackButton(color: Colors.white),
),
body: const Center(
child: RouterOutlet(),
),
);
}
}
class Scrren1 extends StatelessWidget {
const Scrren1({super.key});
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
color: Colors.blue,
child: const Text('Scrren1'),
);
}
}
class Scrren2 extends StatelessWidget {
const Scrren2({super.key});
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
color: Colors.green,
child: const Text('Scrren2'),
);
}
}
/// DemoModule
class DemoModule extends Module {
.....
void routes(RouteManager r) {
r.child('demoHome', child: (_) => const DemoHome(), children: []);
r.child(
'demoPage',
child: (_) => const DemoPage(),
children: [
ChildRoute(
'scrren1',
child: (_) => const Scrren1(),
children: [],
),
ChildRoute(
'scrren2',
child: (_) => const Scrren2(),
children: [],
),
],
);
}
}
/// AppModule
class AppModule extends Module {
.....
@override
void routes(RouteManager r) {
r.module(
'/demo',
module: DemoModule(),
transition: TransitionType.rightToLeft,
guards: [],
);
}
}
////
static String demo = '/demo/demoHome';
static String s1 = '/demo/demoPage/scrren1';
static String s2 = '/demo/demoPage/scrren12';
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Calling Modular.to.pop() or Navigator.of(context).pop() in a widget wrapping a RouterOutlet doesn't dispose of the RouterOutlet's widget tree. This appears to be specific to RouterOutlets displaying a dynamic route. Each time the dynamic route is pushed and popped, the RouterOutlet builds an additional widget tree.
Environment
Add your
flutter doctor -v
To Reproduce
Expected behavior
Each time the floating action button is pressed to navigate to the Child Module's route, the "id" passed into the route should be printed once.
Screenshots
Running on iOS Simulator (17.4)
https://github.com/Flutterando/modular/assets/19160564/f9253516-f72f-45be-a92e-d47eb332cb85
Output:
The text was updated successfully, but these errors were encountered: