title: Flutter persistent sidebar
body: <p>In my application I want to have a sidebar that allows me to have access to specific functions everywhere in my application.</p>
  <hr />
  <p><em><strong>What I want :</strong></em></p>
  <ul>
  <li>That the sidebar remains visible when I push my pages</li>
  <li>That I can pushNamed route or open a modal with one of the sidebar functions</li>
  <li>That I can not display the sidebar on certain pages</li>
  </ul>
  <hr />
  <p><em><strong>What I do :</strong></em></p>
  <p><a href="https://i.stack.imgur.com/dgr7b.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dgr7b.jpg" alt="enter image description here" /></a></p>
  <p>In red, the persistent <code>sidebar</code> and in yellow my <code>app content</code>.</p>
  <p><a href="https://i.stack.imgur.com/21K3M.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/21K3M.jpg" alt="enter image description here" /></a></p>
  <p>If I click on my <code>profil button</code> in the <code>HomeView</code>, the <code>ProfilView</code> is displayed and my sidebar remains visible so it's ok</p>
  <p><a href="https://i.stack.imgur.com/TUy4Q.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TUy4Q.jpg" alt="enter image description here" /></a></p>
  <p>My <code>AppView</code> :</p>
  <pre><code>class AppView extends StatelessWidget {
    const AppView({Key? key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
  
      return MaterialApp(
        title: AppConfig.kAppName,
        debugShowCheckedModeBanner: false,
        theme: AppTheme().data,
        builder: (context, child) =&gt; SidebarTemplate(child: child), // =&gt; I create a template 
        onGenerateRoute: RouterClass.generate,
        initialRoute: RouterName.kHome,
      );
    }
  
  </code></pre>
  <p>My <code>SidebarTemplate</code> : (Display the sidebar and load the page with my router)</p>
  <pre><code>class SidebarTemplate extends StatelessWidget {
    final Widget? child;
    const SidebarTemplate({Key? key, this.child}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return SafeArea(
        child: Scaffold(
          body : Row(
            children: [
              SidebarAtom(), // =&gt; My sidebar Widget
              Expanded(
                child: ClipRect(
                    child: child! // =&gt; My view
                ),
              )
            ],
          )
        ),
      );
    }
  }
  
  </code></pre>
  <p>My <code>RouterClass</code> :</p>
  <pre><code>abstract class RouterClass{
  
    static Route&lt;dynamic&gt; generate(RouteSettings settings){
      final args = settings.arguments;
  
      switch(settings.name){
  
        case RouterName.kHome:
          return MaterialPageRoute(
              builder: (context) =&gt; HomeView()
          );
  
        case RouterName.kProfil:
          return MaterialPageRoute(
              builder: (context) =&gt; ProfilView(title: &quot;Profil&quot;,)
          );
  
        default:
          return MaterialPageRoute(
              builder: (context) =&gt; Error404View(title: &quot;Erreur&quot;)
          );
      }
    }
  }
  </code></pre>
  <hr />
  <p><em><strong>How to do :</strong></em></p>
  <ul>
  <li>To pushNamed or open a modal with a button from my sidebar because I have an error</li>
  </ul>
  <pre><code>The following assertion was thrown while handling a gesture:
  I/flutter (28519): Navigator operation requested with a context that does not include a Navigator.
  I/flutter (28519): The context used to push or pop routes from the Navigator must be that of a widget that is a
  I/flutter (28519): descendant of a Navigator widget.
  </code></pre>
  <ul>
  <li>To hide the sidebar when I want like <code>SplashScreen</code> for example</li>
  </ul>
  <p><strong>Any guidance on the best way to accomplish this would be appreciated.</strong></p>