Skip to content
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

Error launching app on Windows #49

Open
LudmillaAlbertoni opened this issue Jul 29, 2024 · 1 comment
Open

Error launching app on Windows #49

LudmillaAlbertoni opened this issue Jul 29, 2024 · 1 comment

Comments

@LudmillaAlbertoni
Copy link

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:one_context/src/controllers/one_context.dart': Failed assertion: line 16 pos 12: '_context != null': OneContext not initiated! please use builder method.
You need to use the OneContext().builder function to be able to show dialogs and overlays! e.g. ->

MaterialApp(
builder: OneContext().builder,
...
)

If you already set the OneContext().builder early, maybe you are probably trying to use some methods that will only be available after the first MaterialApp build.
OneContext needs to be initialized by MaterialApp before it can be used in the application. This error exception occurs when OneContext context has not yet loaded and you try to use some method that needs the context, such as the showDialog, dismissSnackBar, showSnackBar, showModalBottomSheet, showBottomSheet or popDialog methods.

If you need to use any of these OneContext methods before defining the MaterialApp, a safe way is to check if the OneContext context has already been initialized.
e.g.

  if (OneContext.hasContext) {OneContext().showDialog (...);}

This error happens when you invoke this method

OneThemeController.loadThemeMode (c:\path\pub.dev\one_context-4.0.0\lib\src\controllers\one_theme_controller.dart:81)

Future loadThemeMode() async {
final bool darkMode = await _isDarkModeFromStorage();
_themeMode = darkMode ? ThemeMode.dark : ThemeMode.light;
if (OneContext.hasContext)
OneContext().oneNotifier.notify(OneContext().context,
NotificationPayload(data: OneThemeChangerEvent()));
}

Captura de tela 2024-07-29 153339

@emanuel-braz
Copy link
Owner

working on this #52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants