Closed erickximenes closed 2 years ago
When the project is run on the web, it works normally. But when it runs on mobile this error occurs.
✓ Built build\app\outputs\flutter-apk\app-debug.apk. W/FlutterActivityAndFragmentDelegate(18276): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps. Connecting to VM Service at ws://127.0.0.1:51399/Q2lUOIXl4u4=/ws E/flutter (18276): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:get_it/get_it_impl.dart': Failed assertion: line 404 pos 9: 'instanceFactory.isReady': You tried to access an instance of AuthController that is not ready yet E/flutter (18276): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39) E/flutter (18276): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5) E/flutter (18276): #2 _GetItImplementation.get package:get_it/get_it_impl.dart:404 E/flutter (18276): #3 IsAuth.onNavigation package:meuponto/…/middlewares/AuthGuard.dart:19 E/flutter (18276): #4 StackRouter._canNavigate package:auto_route/…/controller/routing_controller.dart:918 E/flutter (18276): #5 StackRouter._pushAllGuarded package:auto_route/…/controller/routing_controller.dart:867 E/flutter (18276): #6 StackRouter._pushAll package:auto_route/…/controller/routing_controller.dart:847 E/flutter (18276): #7 StackRouter.pushAll package:auto_route/…/controller/routing_controller.dart:752 E/flutter (18276): #8 AutoRouterDelegate.setInitialRoutePath package:auto_route/…/widgets/auto_router_delegate.dart:106 E/flutter (18276): #9 _rootRunUnary (dart:async/zone.dart:1436:47) E/flutter (18276): #10 _CustomZone.runUnary (dart:async/zone.dart:1335:19) E/flutter (18276): <asynchronous suspension> E/flutter (18276):
class IsAuth extends AutoRouteGuard { @override void onNavigation(NavigationResolver resolver, StackRouter router) async { final auth = GetIt.I.get<AuthController>().isAuth; if (auth == true) resolver.next(true); else router.replaceNamed('/auth'); } }
How do you register the AuthController class in GetIt?
As no reply was given I close this now
When the project is run on the web, it works normally. But when it runs on mobile this error occurs.