Open Invincible1996 opened 3 years ago
For your use case, use Get.toNamed('/second', preventDuplicates: false);
Let's leave this issue open, as we can improve this approach. What is happening is that on the back of the second page the navigation stack has a dialog before the home page, so the current route has not been changed yet and the GetX navigation blocks navigation for the same route. Here is a test code to help investigate this bug:
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp(
initialRoute: '/home',
getPages: [
GetPage(
name: '/home',
page: () => HomePage(),
),
GetPage(
name: '/second',
page: () => SecondPage(),
),
],
));
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
initState() {
super.initState();
Future.delayed(Duration(milliseconds: 500), () {
Get.dialog(Material(
type: MaterialType.transparency,
child: Container(
child: Center(
child: RaisedButton(
child: Text('to second'),
onPressed: () async {();
// Works
Get.toNamed('/second', preventDuplicates: false);
// Dont Works
// Get.toNamed('/second');
},
),
),
),
));
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('HomePage')),
body: Container(
color: Colors.white,
child: Center(
child: RaisedButton(
child: Text('to second page'),
onPressed: () => Get.toNamed('/second')),
),
),
);
}
}
class SecondPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('SecondPage')),
body: Container(),
);
}
}
@eduardoflorence @jonataslaw Any updates on this issue?
Sorry !.,preventDuplicates:false worked in my case
Description
Can only open a new page once in a dialog
My suggested solution
Open new page again when click button
Reproduction code
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Can open new page again
Flutter Version:
flutter 1.22.5 stable channel
Getx Version:
get: ^3.22.2
Describe on which device you found the bug:
Both android and iOS devices.