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

Problems I encountered while integrating #2

Closed
YunhuiLiu140502 opened this issue Sep 9, 2020 · 4 comments
Closed

Problems I encountered while integrating #2

YunhuiLiu140502 opened this issue Sep 9, 2020 · 4 comments
Labels
not reproducible not reproducible code provided

Comments

@YunhuiLiu140502
Copy link

image

@emanuel-braz
Copy link
Owner

emanuel-braz commented Sep 22, 2020

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.

onecontext

@emanuel-braz
Copy link
Owner

I’m closing this issue because of inactivity

@maheshlalu
Copy link

I am getting same issue, @emanuel-braz please update on it.

@emanuel-braz
Copy link
Owner

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!

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

No branches or pull requests

3 participants