Comments (4)
Hi @YunhuiLiu140502 , sorry for the delay, I tried to reproduce the problem on my computer, but I couldn't.
Could you check if OneContext is being used elsewhere in the application before MaterialApp starts? 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 (...);}
PS. All widgets below the MaterialApp have full access to the OneContext methods.
from one_context.
Iām closing this issue because of inactivity
from one_context.
I am getting same issue, @emanuel-braz please update on it.
from one_context.
Hi @maheshlalu , there is a reason to show this error, it's because the Flutter needs the context instance to be able to show dialogs. If there is no context, the lib can't do anything about that, unless, warn that something is wrong.
Solutions:
1 - Obviously, do not try show dialogs if there is no context available.(generaly this happens before the MaterialApp get mounted)
2 - If (for a specific reason) you not sure about if the context will be available. Please check it before.
e.g. if (OneContext.hasContext) {OneContext().showDialog(...);}
3 - Send a reproducible code, in order to I investigate deeply if there is a bug.
4 - If none of this works, you can do more for that, please send a PR that fix it. I'll thank you!
from one_context.
Related Issues (20)
- Provider.of<T>(OneContext().context) has error HOT 1
- CupertinoTheme support HOT 1
- Flutter 2.0.1 compatibility HOT 4
- OneContext().popAllDialogs() not working!! HOT 1
- Can I use one_context to optimize my app size? HOT 2
- SnackBar covered by keyboard
- Cannot hide or remove snackbar displayed by OneContext().showSnackBar HOT 4
- flutter 3.0
- Notifications navigation not working properly when application terminate HOT 2
- OneContext().popAllDialogs() or OneContext().popDialogs() don't work. This function pop my screen instead of my dialog HOT 9
- change modal backdrop color HOT 2
- changeMode(ThemeMode.system) not saved HOT 2
- Problems with the snackbar HOT 2
- [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:one_context/src/controllers/navigator_controller.mixin.dart': Failed assertion: line 42 pos 9: '_key != null': Navigator key not found! MaterialApp.navigatorKey is null or not set correctly. HOT 1
- Gorouter navigation breaks when OneContext.builder is used in material app HOT 3
- Not working in flutter web (Please Fix It)
- Already a builder in MaterialApp HOT 3
- routeName always return null HOT 1
- Issue on pop HOT 2
- Please update the package to most latest version of the flutter HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from one_context.