E/flutter (17200): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'findRootAncestorStateOfType' was called on null.
Asked
Active
Viewed 338 times
-2
-
You need to post the minimal complete code that causes this error... – underscore_d Jan 07 '20 at 17:01
2 Answers
0
This error is caused when you are using context before your Widget is build.
Try this code:
WidgetsBinding.instance.addPostFrameCallback((_) {
// put the code here where you are using context.
});
I hope this helps, in case of any doubt please comment. If this answer helps you then please accept and up-vote it.

Kalpesh Kundanani
- 5,413
- 4
- 22
- 32
-1
I got this error when executing some code after calling Navigator.of(context).pop()
. Your BuildContext
object is null.

S Fitz
- 1,074
- 15
- 31
-
-
@iamyadunandan It's an alternate answer, not a question. If you try to use the context after popping it then this error will occur. Please don't downvote when you don't understand. – S Fitz Apr 23 '20 at 06:39