We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
First I try to register PhoenixSocket type and to make sure that GraphQLClient is registered I check
PhoenixSocket
GraphQLClient
print(getIt.isRegistered<GraphQLClient>()); // Register Phoenix Socket getIt.isReady<GraphQLClient>().then((value) => getIt.registerSingletonAsync<PhoenixSocket>( () => Client().initializeSocket()));
And here isinitializeSocket()
initializeSocket()
class Client { Box? box; String? token; Client() { box = getIt<Box>(); token = box!.get("userToken"); } Future<PhoenixSocket> initializeSocket() async { print("Initializing Socket..."); return PhoenixSocket( wsEndpoint, socketOptions: PhoenixSocketOptions( //params: {"token": token}, dynamicParams: (() => getAToken()), ), ); } }
And register another type that depends on PhoenixSocket type.
getIt.isReady<PhoenixSocket>().then((value) => getIt .registerSingleton<ICartChannel>(CartChannel(getIt<PhoenixSocket>())));
But I got an error
E/flutter (10182): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:get_it/get_it_impl.dart': Failed assertion: line 372 pos 7: 'instanceFactory != null': Object/factory with type PhoenixSocket is not registered inside GetIt. E/flutter (10182): (Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance; E/flutter (10182): Did you forget to register it?) E/flutter (10182): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61) E/flutter (10182): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5) E/flutter (10182): #2 _GetItImplementation._findFactoryByNameAndType (package:get_it/get_it_impl.dart:372:7) E/flutter (10182): #3 _GetItImplementation.isReady (package:get_it/get_it_impl.dart:1286:24) E/flutter (10182): #4 afterAuthenticationGetIt (package:myApp/getit_setup.dart:108:9) E/flutter (10182): #5 AuthenticationApi.status (package:myApp/api/apis/authentication_api.dart:74:17) E/flutter (10182): <asynchronous suspension> E/flutter (10182): #6 new AuthenticationBloc.<anonymous closure> (package:myApp/authentication/bloc/authentication_bloc.dart:21:17) E/flutter (10182): <asynchronous suspension>
I tried to find a bug but it took me a day and still can't figure out! Please give me an advice!
The text was updated successfully, but these errors were encountered:
You have to register PhoenixSocket an inside GetIt . I want to see how you get get_it instance because the stacktrace to clair .
Sorry, something went wrong.
you can use the dependsOn parameter to ensure that your first object is ready before the second is registered
dependsOn
No branches or pull requests
First I try to register
PhoenixSocket
type and to make sure thatGraphQLClient
is registered I checkAnd here is
initializeSocket()
And register another type that depends on
PhoenixSocket
type.But I got an error
I tried to find a bug but it took me a day and still can't figure out!
Please give me an advice!
The text was updated successfully, but these errors were encountered: