title: Show Snackbar on top route after closing a page
body: <p>In my app, I have some areas where I can open a new page on top of the current, that allow to edit data. Once editing is done, I want to close the page (i.e. via <code>Navigator.pop(context);</code>), and also show a Snackbar after closing (i.e. via <code>ScaffoldMessenger.of(context).showSnackBar('X has been saved')</code>). I am using a ScaffoldMessenger for that.</p>
  <p>However, if after closing the edit-page only the top-route remains, the Snackbar will not be shown. If I open any other page fast enough, it will be shown there for the remaining time though. So it was triggered, it is just not shown on the top-route. Also, if I open the edit-page not from the top-route, but from any other page that was already opened on top, the Snackbar will show normally after closing the edit-page.</p>
  <p>If I open a Snackbar directly on the top-route, it also works fine. So instead of opening the Snackbar from the edit-page, I could technically return the message and then trigger the Snackbar. But I would prefer not to to pass data around and call functionality at several places, but just call the method at one place (where it belongs).</p>
  <p>I can reproduce this behaviour on a newly created App, just need to replace the <code>_MyHomePageState</code> with the following code. What am I doing wrong here?</p>
  <pre class="lang-dart prettyprint-override"><code>class _MyHomePageState extends State&lt;MyHomePage&gt; {
    final GlobalKey&lt;ScaffoldMessengerState&gt; _globalScaffoldMessengerKey = GlobalKey&lt;ScaffoldMessengerState&gt;();
    @override
    Widget build(BuildContext context) {
      return ScaffoldMessenger(
        key: _globalScaffoldMessengerKey,
        child: Scaffold(
          body: Center(
            child: ElevatedButton(
              onPressed: () {
                Navigator.push&lt;bool&gt;(context, MaterialPageRoute(builder: (context) =&gt; const SubPage()));
              },
              child: const Text(&quot;Open Subpage&quot;),
            ),
          ),
        ),
      );
    }
  }
  
  class SubPage extends StatelessWidget {
    const SubPage({Key? key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              Navigator.pop(context);
              ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Hello Snackbar')));
            },
            child: const Text(&quot;Close Subpage&quot;),
          ),
        ),
      );
    }
  }
  </code></pre>