appKey property
GlobalKey<State<StatefulWidget> >
get
appKey
GlobalKey to detenrminate if a MaterialApp or CupertinoApp
is using the onGenerateRoute
paremeter or for custom transitions
using named routes we need to now the value of routes
parameter
import 'package:flutter_meedu/router.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
key: router.appKey,
navigatorKey: router.navigatorKey, // add the navigator key
home: HomePage(),
routes: {YOUR_ROUTES},
);
}
}
Implementation
GlobalKey get appKey {
_appKey ??= GlobalKey();
return _appKey!;
}