Flutter showDialog with navigator key rather than passing context

Posted by Ramesh Singh | Updated on

Flutter showDialog with navigator key rather than passing context. You can make use of InheritedWidget here. Make a InheritedWidget the root for your application which holds a navigator key. Then you can pass any context of child widgets to get the current navigator state.

Example:

InheritedWidget:

HomeScreen:

The root of the application will look like,


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers