title: Flutter error while using drawer while switching to new page
body: <p>im trying to learn flutter by doing an app, everything was good, but now i get an error while passing trougth a new page with a drawer, and, to be honest idk why but when i implement good the code for page changing the page start to the settings page here down the code</p>
  <pre><code>
  //flutter build apk --split-per-abi
  passToHomePage(BuildContext context) {
    Navigator.push(context, MaterialPageRoute(builder: (context) =&gt; HomePage()));
  }
  
  passToSettingsPage(BuildContext context) {
    Navigator.push(
        context, MaterialPageRoute(builder: (context) =&gt; SettingsStateful()));
  }
  
  Drawer drawerReturner(BuildContext context) {
    return Drawer(
      child: ListView(
        padding: EdgeInsets.zero,
        children: &lt;Widget&gt;[
          Container(
            height: 100,
            child: DrawerHeader(
              decoration: BoxDecoration(
                color: Colors.green,
              ),
              child: Text(
                'Menù',
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 24,
                ),
              ),
            ),
          ),
          ListTile(
            leading: Icon(Icons.add),
            title: Text('&quot;Add&quot; button :D'),
            onTap: passToSettingsPage(context),
          ),
          ListTile(
            leading: Icon(Icons.settings),
            title: Text('Settings (WIP)'),
            onTap: passToSettingsPage(context),
          )
        ],
      ),
    );
  }
  
  void main() {
    runApp(MainApp());
  }
  
  class MainApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'Random app',
        theme: ThemeData(
          primarySwatch: Colors.green,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        home: HomePage(),
      );
    }
  }
  
  class HomePage extends StatefulWidget {
    HomePage({this.title = &quot;Home page&quot;});
  
    final String title;
    @override
    HomePageState createState() =&gt; HomePageState();
  }
  
  class HomePageState extends State&lt;HomePage&gt; {
    int counter = 0;
  
    void incrementCounter() {
      setState(() {
        counter++;
      });
    }
  
    void decrementCounter() {
      setState(() {
        if (counter &gt; -1) {
          counter--;
        }
      });
    }
  
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
            child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: &lt;Widget&gt;[
            if (counter &gt; -1)
              Text('Hai cliccato il bottone $counter volte')
            else
              Text('Non puoi far arrivare il bottone a meno di 0!'),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                FloatingActionButton(
                    onPressed: incrementCounter,
                    tooltip: 'Increment',
                    heroTag: null,
                    child: Icon(Icons.add)),
                Divider(
                  indent: 75,
                ),
                FloatingActionButton(
                    onPressed: decrementCounter,
                    tooltip: 'Decrement',
                    heroTag: null,
                    child: Icon(Icons.remove)),
              ],
            ),
          ],
        )),
        drawer: drawerReturner(context),
      );
    }
  }
  
  class SettingsStateful extends StatefulWidget {
    SettingsStateful({this.title = &quot;Settings&quot;});
  
    final String title;
    @override
    SettingsPage createState() =&gt; SettingsPage();
  }
  
  class SettingsPage extends State&lt;SettingsStateful&gt; {
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: new Center(
          child: Column(children: &lt;Widget&gt;[Text(&quot;Hewwo&quot;)]),
        ),
        drawer: drawerReturner(context),
      );
    }
  }
  </code></pre>
  <p>Here the flutter doctor:</p>
  <pre><code>[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Versione 10.0.19041.508], locale it-IT)
      • Flutter version 1.20.4 at C:\flutter
      • Framework revision fba99f6cf9 (2 weeks ago), 2020-09-14 15:32:52 -0700
      • Engine revision d1bc06f032
      • Dart version 2.9.2
  
  
  [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
      • Android SDK at C:\Users\giuse\AppData\Local\Android\sdk
      • Platform android-30, build-tools 30.0.2
      • Java binary at: D:\Softwares\Android studio\jre\bin\java
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
      • All Android licenses accepted.
  
  [!] Android Studio (version 4.0)
      • Android Studio at D:\Softwares\Android studio
      X Flutter plugin not installed; this adds Flutter specific functionality.
      X Dart plugin not installed; this adds Dart specific functionality.
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
  
  [√] Connected device (1 available)
      • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
  
  ! Doctor found issues in 1 category.
  </code></pre>
  <p>And idk why but errors arent anymore displayed, but here the &quot;main&quot; error</p>
  <p><code>Failed assertion: line 4016 pos 12: '!_debugLocked': is not true.</code></p>