I have this main.dart code:
@override Widget build(BuildContext context) { bool isUserLoggedin = false; return FutureBuilder( future: _checkLoginStatus(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { isUserLoggedin = snapshot.data as bool; return MaterialApp( supportedLocales: L10n.all, locale: _locale, localizationsDelegates: const [ AppLocalizations.delegate, GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], initialRoute: isUserLoggedin ? '/home' : '/login', routes: {'/home': (context) => HomePage(),'/login': (context) => Login(), }, ); } else { return MaterialApp( home: Scaffold( body: Center(child: Text('loading')), ), ); } }); }
and i am facing this error:
Exception has occurred._TypeError (Null check operator used on a null value)
in this code in app.dart:
PlatformRouteInformationProvider? _defaultRouteInformationProvider; BackButtonDispatcher get _effectiveBackButtonDispatcher => widget.backButtonDispatcher ?? _defaultBackButtonDispatcher!; RootBackButtonDispatcher? _defaultBackButtonDispatcher; // NAVIGATOR GlobalKey<NavigatorState>? _navigator; Route<dynamic>? _onGenerateRoute(RouteSettings settings) { final String? name = settings.name; final WidgetBuilder? pageContentBuilder = name == Navigator.defaultRouteName && widget.home != null ? (BuildContext context) => widget.home! //error is here : widget.routes![name]; if (pageContentBuilder != null) { assert( widget.pageRouteBuilder != null,'The default onGenerateRoute handler for WidgetsApp must have a ''pageRouteBuilder set if the home or routes properties are set.', ); final Route<dynamic> route = widget.pageRouteBuilder!<dynamic>( settings, pageContentBuilder, ); return route;
While running my code in debugging mode, I encountered a situation where it gets stuck in a particular section. The error originates from a file named app.dart, which was not authored by me. My main.dart file contains my code, and I am unsure which specific code in app.dart is causing the error.