We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
PopScope or WillPopScope never trigger in Flutter Web.
1. Going To Second Page. 2. Click back button in browser.
` void main() { WidgetsFlutterBinding.ensureInitialized(); runApp(const MyApp()); }
class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key);
@OverRide State createState() => _MyAppState(); }
class _MyAppState extends State {
@OverRide void initState() { super.initState(); Routes.defineRoutes(); }
@OverRide Widget build(BuildContext context) { return MaterialApp( initialRoute: '/', onGenerateRoute: Routes.router.generator, ); } }
class SecondPage extends StatelessWidget {
Widget build(BuildContext context) { return PopScope( canPop: false, onPopInvoked: (bool didPop) { if (didPop) { return; } }, child: Scaffold( backgroundColor: Colors.red, body: Container(), ), ); }
}
class HomePage extends StatelessWidget {
Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.blue, body: Container( child: ElevatedButton( child: const Text("Button 1"), onPressed: () => Navigator.pushNamed(context, 'second'), ),
), );
class Routes { static final router = FluroRouter();
static var firstScreen = Handler( handlerFunc: (BuildContext ? context, Map<String, dynamic> params) { return HomePage(); });
static var secondScreen = Handler( handlerFunc: (BuildContext ? context, Map<String, dynamic> params) { return SecondPage(); });
static dynamic defineRoutes() { router.define("/", handler: firstScreen,transitionType: TransitionType.fadeIn); router.define("second", handler: secondScreen,transitionType: TransitionType.inFromLeft); }
} `
The text was updated successfully, but these errors were encountered:
No branches or pull requests
PopScope or WillPopScope never trigger in Flutter Web.
1. Going To Second Page.
2. Click back button in browser.
`
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@OverRide
State createState() => _MyAppState();
}
class _MyAppState extends State {
@OverRide
void initState() {
super.initState();
Routes.defineRoutes();
}
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: '/',
onGenerateRoute: Routes.router.generator,
);
}
}
class SecondPage extends StatelessWidget {
Widget build(BuildContext context) {
return PopScope(
canPop: false,
onPopInvoked: (bool didPop) {
if (didPop) {
return;
}
},
child: Scaffold(
backgroundColor: Colors.red,
body: Container(),
),
);
}
}
class HomePage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
body: Container(
child: ElevatedButton(
child: const Text("Button 1"),
onPressed: () => Navigator.pushNamed(context, 'second'),
),
}
}
class Routes {
static final router = FluroRouter();
static var firstScreen = Handler(
handlerFunc: (BuildContext ? context, Map<String, dynamic> params) {
return HomePage();
});
static var secondScreen = Handler(
handlerFunc: (BuildContext ? context, Map<String, dynamic> params) {
return SecondPage();
});
static dynamic defineRoutes() {
router.define("/", handler: firstScreen,transitionType: TransitionType.fadeIn);
router.define("second", handler: secondScreen,transitionType: TransitionType.inFromLeft);
}
}
`
The text was updated successfully, but these errors were encountered: