New issue
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
Document WidgetsFlutterBinding.ensureInitialized for early plugin calls #77745
Comments
This is not true for all the cases, this is only required if your uses shared_preferences is needed before
From what I know this kind of issue is mostly related to Proguard configurations (and sometimes Gradle version).
Can you please elaborate how you came to this conclusion? |
You are 100% right .... I concluded this without exhaustive testing ... I did follow instructions with ProGuard and that did not fix my "No implementation found for method getAll" .... but when I moved the init of SharedPreferences down into the widget, I finally (after days of experimenting) got past this PITA error. And if I count all the weeks I relied on "SharedPreferences.setMockInitialValues()" BEFORE Flutter 2.0 and null safety, I've had this error pestering me for months I would love to see some clear specs on configuring Proguard and setting up Gradle ... thanks for the info!! |
While I agree that this should be done, notice that this may not be the solution for everyone, as an example, this may be caused by how the plugins are being registered (#75416). For the Firebase plugin request, please file a new issue in its repository: https://github.com/FirebaseExtended/flutterfire/issues |
You prompted me to dig more deeply and it turned out that our problem was not with SharePreferences at all ... that was just the error we were seeing. It was actually caused by plugin "flutter_facebook_auth" failing to register upstream and leaving Flutter's plugin infrastructure in a confused state, so that it was reporting the error with the next plugin to come along. Bogus error about SharePreferences sent us on a totally irrelevant wild goose chase!! We don't have any current problems with Firebase .... it seems to be working fine. |
We should ensure that |
@stuartmorgan should this be documented while calling |
Closing as a duplicate of #78028 which has more detail. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Certain plugins (eg await Firebase.initializeApp();) CAN be called BEFORE runApp() ... at top of:
void main() async {}
others (await SharedPreferences.getInstance(); ) MUST be called from a Widget INSIDE of runApp()
This was confusing to me and has not been clearly stated in any docs I've been able to find.
I suspect a lot of the people seeing "shared_preferences -- No implementation found for method getAll" were making the same mistake as I was ... trying to bind SharedPreferences too early in the load sequence.
The text was updated successfully, but these errors were encountered: