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
@Milad-Akarie We found issue in Auto routes library, when we use PopScope and set canPop to false.
onPopInvoked boolean parameter always gives "true" even when canPop is "false", only in flutter web, works fine in mobile.
onPopInvoked also works correct, when flutter's Navigator class is used, but does not work with auto routes.
Note: Use browser back button to go to previous page (not in app back button)
Versions: auto_route: ^8.1.3 auto_route_generator: 8.0.0
flutter version Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision 5dcb86f68f (4 weeks ago) • 2024-05-09 07:39:20 -0500 Engine • revision f6344b75dc Tools • Dart 3.4.0 • DevTools 2.34.3
main.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:navigation_test/router.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp(); @override Widget build(BuildContext context) { return MaterialApp.router( routerConfig: AppRouter().config(), title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), ); } } @RoutePage() class MyHomePage extends StatefulWidget { const MyHomePage(); @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { void _incrementCounter() { AutoRouter.of(context).navigate(MySecondPageRoute()); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text("Test, test"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ const Text( 'You have pushed the button this many times:', ), Text( '', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); } } @RoutePage() class MySecondPage extends StatefulWidget { const MySecondPage(); @override State<MySecondPage> createState() => _MySecondPageState(); } class _MySecondPageState extends State<MySecondPage> { @override Widget build(BuildContext context) { return PopScope( canPop: false, onPopInvoked: (didPop) { print("onPopInvoked onPopInvoked"); print("didPop $didPop"); //always prints true in web. <<<<<<-------------------- }, child: Scaffold( appBar: AppBar( leading: IconButton(onPressed: () {}, icon: const Icon(Icons.arrow_back)), ), body: const Placeholder(), ), ); } }
router.dart
import "package:auto_route/auto_route.dart"; import 'package:flutter/material.dart'; import 'main.dart'; part "router.gr.dart"; @AutoRouterConfig(replaceInRouteName: "Screen,Route,Page") class AppRouter extends _$AppRouter { @override List<AutoRoute> get routes => [ AutoRoute( page: MyHomePageRoute.page, initial: true, path: "/home", ), AutoRoute( page: MySecondPageRoute.page, path: "/second", ), ]; }
The text was updated successfully, but these errors were encountered:
Hey @tw-manishp please refer to this #1944
Sorry, something went wrong.
No branches or pull requests
@Milad-Akarie We found issue in Auto routes library, when we use PopScope and set canPop to false.
onPopInvoked boolean parameter always gives "true" even when canPop is "false", only in flutter web, works fine in mobile.
onPopInvoked also works correct, when flutter's Navigator class is used, but does not work with auto routes.
Note:
Use browser back button to go to previous page (not in app back button)
Versions:
auto_route: ^8.1.3
auto_route_generator: 8.0.0
flutter version
Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5dcb86f68f (4 weeks ago) • 2024-05-09 07:39:20 -0500
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.3
main.dart
router.dart
The text was updated successfully, but these errors were encountered: