showDialog from root widget












0














I want to show a dialog from root widget (the one that created MaterialApp) I have a NavigatorState instance, but showDialog requires context that would return Navigator.of(context).



It looks like I need to provide context from a route, but I can't do this, because the root widget does not have it.



EDIT: I have found a workaround: I can push fake route that is only there to showDialog and then pop that route when dialog finishes. Not pretty but works.










share|improve this question





























    0














    I want to show a dialog from root widget (the one that created MaterialApp) I have a NavigatorState instance, but showDialog requires context that would return Navigator.of(context).



    It looks like I need to provide context from a route, but I can't do this, because the root widget does not have it.



    EDIT: I have found a workaround: I can push fake route that is only there to showDialog and then pop that route when dialog finishes. Not pretty but works.










    share|improve this question



























      0












      0








      0







      I want to show a dialog from root widget (the one that created MaterialApp) I have a NavigatorState instance, but showDialog requires context that would return Navigator.of(context).



      It looks like I need to provide context from a route, but I can't do this, because the root widget does not have it.



      EDIT: I have found a workaround: I can push fake route that is only there to showDialog and then pop that route when dialog finishes. Not pretty but works.










      share|improve this question















      I want to show a dialog from root widget (the one that created MaterialApp) I have a NavigatorState instance, but showDialog requires context that would return Navigator.of(context).



      It looks like I need to provide context from a route, but I can't do this, because the root widget does not have it.



      EDIT: I have found a workaround: I can push fake route that is only there to showDialog and then pop that route when dialog finishes. Not pretty but works.







      flutter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 7:31

























      asked Nov 14 '18 at 6:49









      krzat

      32728




      32728
























          3 Answers
          3






          active

          oldest

          votes


















          2














          I fixed the problem by using navigator.overlay.context. Here is example:



          import 'package:flutter/material.dart';

          void main() => runApp(new MyApp());

          class MyApp extends StatelessWidget {
          final navigatorKey = GlobalKey<NavigatorState>();

          void show() {
          final context = navigatorKey.currentState.overlay.context;
          final dialog = AlertDialog(
          content: Text('Test'),
          );
          showDialog(context: context, builder: (x) => dialog);
          }

          @override
          Widget build(BuildContext context) {
          return new MaterialApp(
          navigatorKey: navigatorKey,
          theme: new ThemeData(
          primarySwatch: Colors.blue,
          ),
          home: Scaffold(
          appBar: AppBar(),
          body: FlatButton(
          child: Text('Show alert'),
          onPressed: show,
          ),
          ),
          );
          }
          }





          share|improve this answer





























            1














            tl;dr: If you want to call showDialog from your root widget, extrude your code into another widget (e.g. a StatelessWidget), and call showDialog there.



            Anyway, in the following I'm going to assume you are running into this issue:



            flutter: No MaterialLocalizations found. 
            flutter: MyApp widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
            flutter: Localizations are used to generate many different messages, labels,and abbreviations which are used by the material library.


            As said before, showDialog can only be called in a BuildContext whose ancestor has a MaterialApp. Therefore you can't directly call showDialogif you have a structure like this:



            - MaterialApp
            - Scaffold
            - Button // call show Dialog here


            In a code example this would result in code like this, throwing the error given above:



            import 'package:flutter/material.dart';

            void main() => runApp(MyApp());

            class MyApp extends StatelessWidget {
            @override
            Widget build(BuildContext context) {
            return MaterialApp(
            theme: ThemeData(),
            home: Scaffold(
            body: Center(
            child: RaisedButton(
            child: Text('Show dialog!'),
            onPressed: () {
            showDialog(
            context: context,
            builder: (BuildContext context) {
            return Dialog(
            child: Text('Dialog.'),
            );
            });
            }),
            ),
            ),
            );
            }
            }


            To solve this error from occuring you can create a new Widget, which has its own BuildContext. The modified structure would look like this:



            - MaterialApp
            - Home

            - Home // your own (Stateless)Widget
            - Button // call show Dialog here


            Modifying the code example to the structure given above, results in the code snippet below. showDialogcan be called without throwing the error.



            import 'package:flutter/material.dart';

            void main() => runApp(MyApp());

            class MyApp extends StatelessWidget {
            @override
            Widget build(BuildContext context) {
            return MaterialApp(
            theme: ThemeData(),
            home: Home()
            );
            }
            }

            class Home extends StatelessWidget {
            @override
            Widget build(BuildContext context) {
            return Scaffold(
            body: Center(
            child: RaisedButton(
            child: Text('Show dialog!'),
            onPressed: () {
            showDialog(
            context: context,
            builder: (BuildContext context) {
            return Dialog(
            child: Text('Dialog.'),
            );
            });
            }),
            ),
            );
            }
            }





            share|improve this answer





















            • Obviously this will work, but my use case is for example showing alert when notifications comes in. It can happen in any state of the app, therefore I don't have specific page to show the dialog in. Maybe if there was one page that is always in hierarchy it could work, but that's not the case for my app currently.
              – krzat
              Nov 14 '18 at 8:59










            • @krzat Oh sorry, maybe you wanna try using the Overlay widget instead. If you have a NavigatorState, there shouldn't be a problem with displaying it (example). To create the same effect as with the showDialog function, you can make it full screen size and give it a background-color with opacity.
              – Niklas
              Nov 14 '18 at 9:09










            • Maybe navigator.overlay.context will do the trick, I will check that.
              – krzat
              Nov 14 '18 at 18:16





















            0














            Since showDialog is used for showing a material dialog It can be used for showing dialogs inside a MaterialApp widget only. It can not be used to show dialog outside it.






            share|improve this answer





















            • I have a reference to NavigatorState so I don't see why it shouldn't be possible.
              – krzat
              Nov 14 '18 at 7:32











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294551%2fshowdialog-from-root-widget%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            I fixed the problem by using navigator.overlay.context. Here is example:



            import 'package:flutter/material.dart';

            void main() => runApp(new MyApp());

            class MyApp extends StatelessWidget {
            final navigatorKey = GlobalKey<NavigatorState>();

            void show() {
            final context = navigatorKey.currentState.overlay.context;
            final dialog = AlertDialog(
            content: Text('Test'),
            );
            showDialog(context: context, builder: (x) => dialog);
            }

            @override
            Widget build(BuildContext context) {
            return new MaterialApp(
            navigatorKey: navigatorKey,
            theme: new ThemeData(
            primarySwatch: Colors.blue,
            ),
            home: Scaffold(
            appBar: AppBar(),
            body: FlatButton(
            child: Text('Show alert'),
            onPressed: show,
            ),
            ),
            );
            }
            }





            share|improve this answer


























              2














              I fixed the problem by using navigator.overlay.context. Here is example:



              import 'package:flutter/material.dart';

              void main() => runApp(new MyApp());

              class MyApp extends StatelessWidget {
              final navigatorKey = GlobalKey<NavigatorState>();

              void show() {
              final context = navigatorKey.currentState.overlay.context;
              final dialog = AlertDialog(
              content: Text('Test'),
              );
              showDialog(context: context, builder: (x) => dialog);
              }

              @override
              Widget build(BuildContext context) {
              return new MaterialApp(
              navigatorKey: navigatorKey,
              theme: new ThemeData(
              primarySwatch: Colors.blue,
              ),
              home: Scaffold(
              appBar: AppBar(),
              body: FlatButton(
              child: Text('Show alert'),
              onPressed: show,
              ),
              ),
              );
              }
              }





              share|improve this answer
























                2












                2








                2






                I fixed the problem by using navigator.overlay.context. Here is example:



                import 'package:flutter/material.dart';

                void main() => runApp(new MyApp());

                class MyApp extends StatelessWidget {
                final navigatorKey = GlobalKey<NavigatorState>();

                void show() {
                final context = navigatorKey.currentState.overlay.context;
                final dialog = AlertDialog(
                content: Text('Test'),
                );
                showDialog(context: context, builder: (x) => dialog);
                }

                @override
                Widget build(BuildContext context) {
                return new MaterialApp(
                navigatorKey: navigatorKey,
                theme: new ThemeData(
                primarySwatch: Colors.blue,
                ),
                home: Scaffold(
                appBar: AppBar(),
                body: FlatButton(
                child: Text('Show alert'),
                onPressed: show,
                ),
                ),
                );
                }
                }





                share|improve this answer












                I fixed the problem by using navigator.overlay.context. Here is example:



                import 'package:flutter/material.dart';

                void main() => runApp(new MyApp());

                class MyApp extends StatelessWidget {
                final navigatorKey = GlobalKey<NavigatorState>();

                void show() {
                final context = navigatorKey.currentState.overlay.context;
                final dialog = AlertDialog(
                content: Text('Test'),
                );
                showDialog(context: context, builder: (x) => dialog);
                }

                @override
                Widget build(BuildContext context) {
                return new MaterialApp(
                navigatorKey: navigatorKey,
                theme: new ThemeData(
                primarySwatch: Colors.blue,
                ),
                home: Scaffold(
                appBar: AppBar(),
                body: FlatButton(
                child: Text('Show alert'),
                onPressed: show,
                ),
                ),
                );
                }
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 17 '18 at 11:15









                krzat

                32728




                32728

























                    1














                    tl;dr: If you want to call showDialog from your root widget, extrude your code into another widget (e.g. a StatelessWidget), and call showDialog there.



                    Anyway, in the following I'm going to assume you are running into this issue:



                    flutter: No MaterialLocalizations found. 
                    flutter: MyApp widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
                    flutter: Localizations are used to generate many different messages, labels,and abbreviations which are used by the material library.


                    As said before, showDialog can only be called in a BuildContext whose ancestor has a MaterialApp. Therefore you can't directly call showDialogif you have a structure like this:



                    - MaterialApp
                    - Scaffold
                    - Button // call show Dialog here


                    In a code example this would result in code like this, throwing the error given above:



                    import 'package:flutter/material.dart';

                    void main() => runApp(MyApp());

                    class MyApp extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return MaterialApp(
                    theme: ThemeData(),
                    home: Scaffold(
                    body: Center(
                    child: RaisedButton(
                    child: Text('Show dialog!'),
                    onPressed: () {
                    showDialog(
                    context: context,
                    builder: (BuildContext context) {
                    return Dialog(
                    child: Text('Dialog.'),
                    );
                    });
                    }),
                    ),
                    ),
                    );
                    }
                    }


                    To solve this error from occuring you can create a new Widget, which has its own BuildContext. The modified structure would look like this:



                    - MaterialApp
                    - Home

                    - Home // your own (Stateless)Widget
                    - Button // call show Dialog here


                    Modifying the code example to the structure given above, results in the code snippet below. showDialogcan be called without throwing the error.



                    import 'package:flutter/material.dart';

                    void main() => runApp(MyApp());

                    class MyApp extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return MaterialApp(
                    theme: ThemeData(),
                    home: Home()
                    );
                    }
                    }

                    class Home extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return Scaffold(
                    body: Center(
                    child: RaisedButton(
                    child: Text('Show dialog!'),
                    onPressed: () {
                    showDialog(
                    context: context,
                    builder: (BuildContext context) {
                    return Dialog(
                    child: Text('Dialog.'),
                    );
                    });
                    }),
                    ),
                    );
                    }
                    }





                    share|improve this answer





















                    • Obviously this will work, but my use case is for example showing alert when notifications comes in. It can happen in any state of the app, therefore I don't have specific page to show the dialog in. Maybe if there was one page that is always in hierarchy it could work, but that's not the case for my app currently.
                      – krzat
                      Nov 14 '18 at 8:59










                    • @krzat Oh sorry, maybe you wanna try using the Overlay widget instead. If you have a NavigatorState, there shouldn't be a problem with displaying it (example). To create the same effect as with the showDialog function, you can make it full screen size and give it a background-color with opacity.
                      – Niklas
                      Nov 14 '18 at 9:09










                    • Maybe navigator.overlay.context will do the trick, I will check that.
                      – krzat
                      Nov 14 '18 at 18:16


















                    1














                    tl;dr: If you want to call showDialog from your root widget, extrude your code into another widget (e.g. a StatelessWidget), and call showDialog there.



                    Anyway, in the following I'm going to assume you are running into this issue:



                    flutter: No MaterialLocalizations found. 
                    flutter: MyApp widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
                    flutter: Localizations are used to generate many different messages, labels,and abbreviations which are used by the material library.


                    As said before, showDialog can only be called in a BuildContext whose ancestor has a MaterialApp. Therefore you can't directly call showDialogif you have a structure like this:



                    - MaterialApp
                    - Scaffold
                    - Button // call show Dialog here


                    In a code example this would result in code like this, throwing the error given above:



                    import 'package:flutter/material.dart';

                    void main() => runApp(MyApp());

                    class MyApp extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return MaterialApp(
                    theme: ThemeData(),
                    home: Scaffold(
                    body: Center(
                    child: RaisedButton(
                    child: Text('Show dialog!'),
                    onPressed: () {
                    showDialog(
                    context: context,
                    builder: (BuildContext context) {
                    return Dialog(
                    child: Text('Dialog.'),
                    );
                    });
                    }),
                    ),
                    ),
                    );
                    }
                    }


                    To solve this error from occuring you can create a new Widget, which has its own BuildContext. The modified structure would look like this:



                    - MaterialApp
                    - Home

                    - Home // your own (Stateless)Widget
                    - Button // call show Dialog here


                    Modifying the code example to the structure given above, results in the code snippet below. showDialogcan be called without throwing the error.



                    import 'package:flutter/material.dart';

                    void main() => runApp(MyApp());

                    class MyApp extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return MaterialApp(
                    theme: ThemeData(),
                    home: Home()
                    );
                    }
                    }

                    class Home extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return Scaffold(
                    body: Center(
                    child: RaisedButton(
                    child: Text('Show dialog!'),
                    onPressed: () {
                    showDialog(
                    context: context,
                    builder: (BuildContext context) {
                    return Dialog(
                    child: Text('Dialog.'),
                    );
                    });
                    }),
                    ),
                    );
                    }
                    }





                    share|improve this answer





















                    • Obviously this will work, but my use case is for example showing alert when notifications comes in. It can happen in any state of the app, therefore I don't have specific page to show the dialog in. Maybe if there was one page that is always in hierarchy it could work, but that's not the case for my app currently.
                      – krzat
                      Nov 14 '18 at 8:59










                    • @krzat Oh sorry, maybe you wanna try using the Overlay widget instead. If you have a NavigatorState, there shouldn't be a problem with displaying it (example). To create the same effect as with the showDialog function, you can make it full screen size and give it a background-color with opacity.
                      – Niklas
                      Nov 14 '18 at 9:09










                    • Maybe navigator.overlay.context will do the trick, I will check that.
                      – krzat
                      Nov 14 '18 at 18:16
















                    1












                    1








                    1






                    tl;dr: If you want to call showDialog from your root widget, extrude your code into another widget (e.g. a StatelessWidget), and call showDialog there.



                    Anyway, in the following I'm going to assume you are running into this issue:



                    flutter: No MaterialLocalizations found. 
                    flutter: MyApp widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
                    flutter: Localizations are used to generate many different messages, labels,and abbreviations which are used by the material library.


                    As said before, showDialog can only be called in a BuildContext whose ancestor has a MaterialApp. Therefore you can't directly call showDialogif you have a structure like this:



                    - MaterialApp
                    - Scaffold
                    - Button // call show Dialog here


                    In a code example this would result in code like this, throwing the error given above:



                    import 'package:flutter/material.dart';

                    void main() => runApp(MyApp());

                    class MyApp extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return MaterialApp(
                    theme: ThemeData(),
                    home: Scaffold(
                    body: Center(
                    child: RaisedButton(
                    child: Text('Show dialog!'),
                    onPressed: () {
                    showDialog(
                    context: context,
                    builder: (BuildContext context) {
                    return Dialog(
                    child: Text('Dialog.'),
                    );
                    });
                    }),
                    ),
                    ),
                    );
                    }
                    }


                    To solve this error from occuring you can create a new Widget, which has its own BuildContext. The modified structure would look like this:



                    - MaterialApp
                    - Home

                    - Home // your own (Stateless)Widget
                    - Button // call show Dialog here


                    Modifying the code example to the structure given above, results in the code snippet below. showDialogcan be called without throwing the error.



                    import 'package:flutter/material.dart';

                    void main() => runApp(MyApp());

                    class MyApp extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return MaterialApp(
                    theme: ThemeData(),
                    home: Home()
                    );
                    }
                    }

                    class Home extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return Scaffold(
                    body: Center(
                    child: RaisedButton(
                    child: Text('Show dialog!'),
                    onPressed: () {
                    showDialog(
                    context: context,
                    builder: (BuildContext context) {
                    return Dialog(
                    child: Text('Dialog.'),
                    );
                    });
                    }),
                    ),
                    );
                    }
                    }





                    share|improve this answer












                    tl;dr: If you want to call showDialog from your root widget, extrude your code into another widget (e.g. a StatelessWidget), and call showDialog there.



                    Anyway, in the following I'm going to assume you are running into this issue:



                    flutter: No MaterialLocalizations found. 
                    flutter: MyApp widgets require MaterialLocalizations to be provided by a Localizations widget ancestor.
                    flutter: Localizations are used to generate many different messages, labels,and abbreviations which are used by the material library.


                    As said before, showDialog can only be called in a BuildContext whose ancestor has a MaterialApp. Therefore you can't directly call showDialogif you have a structure like this:



                    - MaterialApp
                    - Scaffold
                    - Button // call show Dialog here


                    In a code example this would result in code like this, throwing the error given above:



                    import 'package:flutter/material.dart';

                    void main() => runApp(MyApp());

                    class MyApp extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return MaterialApp(
                    theme: ThemeData(),
                    home: Scaffold(
                    body: Center(
                    child: RaisedButton(
                    child: Text('Show dialog!'),
                    onPressed: () {
                    showDialog(
                    context: context,
                    builder: (BuildContext context) {
                    return Dialog(
                    child: Text('Dialog.'),
                    );
                    });
                    }),
                    ),
                    ),
                    );
                    }
                    }


                    To solve this error from occuring you can create a new Widget, which has its own BuildContext. The modified structure would look like this:



                    - MaterialApp
                    - Home

                    - Home // your own (Stateless)Widget
                    - Button // call show Dialog here


                    Modifying the code example to the structure given above, results in the code snippet below. showDialogcan be called without throwing the error.



                    import 'package:flutter/material.dart';

                    void main() => runApp(MyApp());

                    class MyApp extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return MaterialApp(
                    theme: ThemeData(),
                    home: Home()
                    );
                    }
                    }

                    class Home extends StatelessWidget {
                    @override
                    Widget build(BuildContext context) {
                    return Scaffold(
                    body: Center(
                    child: RaisedButton(
                    child: Text('Show dialog!'),
                    onPressed: () {
                    showDialog(
                    context: context,
                    builder: (BuildContext context) {
                    return Dialog(
                    child: Text('Dialog.'),
                    );
                    });
                    }),
                    ),
                    );
                    }
                    }






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 14 '18 at 8:55









                    Niklas

                    41417




                    41417












                    • Obviously this will work, but my use case is for example showing alert when notifications comes in. It can happen in any state of the app, therefore I don't have specific page to show the dialog in. Maybe if there was one page that is always in hierarchy it could work, but that's not the case for my app currently.
                      – krzat
                      Nov 14 '18 at 8:59










                    • @krzat Oh sorry, maybe you wanna try using the Overlay widget instead. If you have a NavigatorState, there shouldn't be a problem with displaying it (example). To create the same effect as with the showDialog function, you can make it full screen size and give it a background-color with opacity.
                      – Niklas
                      Nov 14 '18 at 9:09










                    • Maybe navigator.overlay.context will do the trick, I will check that.
                      – krzat
                      Nov 14 '18 at 18:16




















                    • Obviously this will work, but my use case is for example showing alert when notifications comes in. It can happen in any state of the app, therefore I don't have specific page to show the dialog in. Maybe if there was one page that is always in hierarchy it could work, but that's not the case for my app currently.
                      – krzat
                      Nov 14 '18 at 8:59










                    • @krzat Oh sorry, maybe you wanna try using the Overlay widget instead. If you have a NavigatorState, there shouldn't be a problem with displaying it (example). To create the same effect as with the showDialog function, you can make it full screen size and give it a background-color with opacity.
                      – Niklas
                      Nov 14 '18 at 9:09










                    • Maybe navigator.overlay.context will do the trick, I will check that.
                      – krzat
                      Nov 14 '18 at 18:16


















                    Obviously this will work, but my use case is for example showing alert when notifications comes in. It can happen in any state of the app, therefore I don't have specific page to show the dialog in. Maybe if there was one page that is always in hierarchy it could work, but that's not the case for my app currently.
                    – krzat
                    Nov 14 '18 at 8:59




                    Obviously this will work, but my use case is for example showing alert when notifications comes in. It can happen in any state of the app, therefore I don't have specific page to show the dialog in. Maybe if there was one page that is always in hierarchy it could work, but that's not the case for my app currently.
                    – krzat
                    Nov 14 '18 at 8:59












                    @krzat Oh sorry, maybe you wanna try using the Overlay widget instead. If you have a NavigatorState, there shouldn't be a problem with displaying it (example). To create the same effect as with the showDialog function, you can make it full screen size and give it a background-color with opacity.
                    – Niklas
                    Nov 14 '18 at 9:09




                    @krzat Oh sorry, maybe you wanna try using the Overlay widget instead. If you have a NavigatorState, there shouldn't be a problem with displaying it (example). To create the same effect as with the showDialog function, you can make it full screen size and give it a background-color with opacity.
                    – Niklas
                    Nov 14 '18 at 9:09












                    Maybe navigator.overlay.context will do the trick, I will check that.
                    – krzat
                    Nov 14 '18 at 18:16






                    Maybe navigator.overlay.context will do the trick, I will check that.
                    – krzat
                    Nov 14 '18 at 18:16













                    0














                    Since showDialog is used for showing a material dialog It can be used for showing dialogs inside a MaterialApp widget only. It can not be used to show dialog outside it.






                    share|improve this answer





















                    • I have a reference to NavigatorState so I don't see why it shouldn't be possible.
                      – krzat
                      Nov 14 '18 at 7:32
















                    0














                    Since showDialog is used for showing a material dialog It can be used for showing dialogs inside a MaterialApp widget only. It can not be used to show dialog outside it.






                    share|improve this answer





















                    • I have a reference to NavigatorState so I don't see why it shouldn't be possible.
                      – krzat
                      Nov 14 '18 at 7:32














                    0












                    0








                    0






                    Since showDialog is used for showing a material dialog It can be used for showing dialogs inside a MaterialApp widget only. It can not be used to show dialog outside it.






                    share|improve this answer












                    Since showDialog is used for showing a material dialog It can be used for showing dialogs inside a MaterialApp widget only. It can not be used to show dialog outside it.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 14 '18 at 7:15









                    vipin agrahari

                    6101518




                    6101518












                    • I have a reference to NavigatorState so I don't see why it shouldn't be possible.
                      – krzat
                      Nov 14 '18 at 7:32


















                    • I have a reference to NavigatorState so I don't see why it shouldn't be possible.
                      – krzat
                      Nov 14 '18 at 7:32
















                    I have a reference to NavigatorState so I don't see why it shouldn't be possible.
                    – krzat
                    Nov 14 '18 at 7:32




                    I have a reference to NavigatorState so I don't see why it shouldn't be possible.
                    – krzat
                    Nov 14 '18 at 7:32


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294551%2fshowdialog-from-root-widget%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Guess what letter conforming each word

                    Port of Spain

                    Run scheduled task as local user group (not BUILTIN)