Closed nyck33 closed 3 years ago
The example redirection.dart
looks like
/// sample app using redirection to another location
class App extends StatelessWidget {
App({Key? key}) : super(key: key);
final loginInfo = LoginInfo();
// add the login info into the tree as app state that can change over time
@override
Widget build(BuildContext context) => ChangeNotifierProvider<LoginInfo>.value(
value: loginInfo,
child: MaterialApp.router(
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
title: 'GoRouter Example: Redirection',
debugShowCheckedModeBanner: false,
),
);
.
.
.
loginInfo
looks like an instance member there too but it can be accessed. What's the difference between the example and mine?
What's the error?
@csells
The instance member 'loginInfo' can't be accessed in an initializer.
Try replacing the reference to the instance member with a different expressiond
Try replacing this:
final _router = GoRouter(...)
With this:
late final _router = GoRouter(...)
Thank you Mr. Sells, I apologize for not being more experimental. I was being lazy, get it?
I tried to copy that one like this:
But it's telling me I cannot access
loginInfo
. Why is that?