title: Why Isn't Navigator pushNamedAndRemoveUntil is not working as expected?
body: <p><a href="http://www.mediafire.com/file/hq4p5i9bjtz36m8/copy.zip/file" rel="nofollow noreferrer">Source</a><br>
  In my app I have a basic app drawer with inkwells to handle gestures(taps). </p>
  
  <p>I am using provider to change my theme, but when i use my app drawer to go to any named route it removes the initial route even though I am using <code>pushNamedAndRemoveUntil</code>.   </p>
  
  <p>However <strong>this works when i change my theme</strong>. For example when I go to <strong>settings_screen.dart</strong> and use the switch to change my theme from light to dark the back button appears i.e my inital route.
  What is the reason for this strange behavior?<br>
  <strong>main.dart</strong>  </p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:provider/provider.dart';
  
  //Providers
  import './providers/themes.dart';
  
  //screens
  import './screens/home_screen.dart';
  import './screens/about_screen.dart';
  import './screens/news_screen.dart';
  import './screens/department_screen.dart';
  import './screens/admission_screen.dart';
  import './screens/placements_screen.dart';
  import './screens/contact_us_screen.dart';
  import './screens/settings_screen.dart';
  
  void main() =&gt; runApp(SfitApp());
  
  class SfitApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return ChangeNotifierProvider&lt;Themes&gt;(
        create: (_) =&gt; Themes(),
        child: MaterialAppWithTheme(),
      );
    }
  }
  
  class MaterialAppWithTheme extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      final theme = Provider.of&lt;Themes&gt;(context);
      return MaterialApp(
        title: "SFIT App",
        //routes
        initialRoute: '/',
        routes: {
          '/': (context) =&gt; HomeScreen(),
          AboutScreen.routeName: (context) =&gt; AboutScreen(),
          NewsScreen.routeName: (context) =&gt; NewsScreen(),
          AdmissionScreen.routeName: (context) =&gt; AdmissionScreen(),
          DepartmentScreen.routeName: (context) =&gt; DepartmentScreen(),
          PlacementsScreen.routeName: (context) =&gt; PlacementsScreen(),
          ContactUsScreen.routeName: (context) =&gt; ContactUsScreen(),
          SettingsScreen.routeName: (context) =&gt; SettingsScreen(),
        },
        //theme
        theme: theme.getTheme(),
      );
    }
  }
  </code></pre>
  
  <p><strong>app drawer</strong></p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  //constants
  import '../constants.dart';
  
  //screens
  import '../screens/home_screen.dart';
  import '../screens/settings_screen.dart';
  
  class AppDrawer extends StatelessWidget {
    final String title;
  
    AppDrawer({@required this.title});
  
    @override
    Widget build(BuildContext context) {
      return Drawer(
        child: ListView(
          children: &lt;Widget&gt;[
            DrawerHeader(
              child: Text(
                title,
                style: Theme.of(context).textTheme.title,
              ),
            ),
  
  //          Home
            InkWell(
              splashColor: Colors.lightBlueAccent,
              borderRadius: BorderRadius.circular(6),
              onTap: () {
                Navigator.of(context).popUntil(
                  ModalRoute.withName('/'),
                );
              },
              child: ListTile(
                leading: ClipRRect(
                  borderRadius: BorderRadius.circular(5),
                  child: Container(
                    padding: EdgeInsets.all(7),
                    color: Colors.lightBlueAccent,
                    child: Icon(Icons.home, color: Colors.white),
                  ),
                ),
                title: Text(
                  'Home',
                  style: Theme.of(context).textTheme.bodyText2,
                ),
              ),
            ),
  //          About
            NavigationDrawerItem(appSections[0]),
  //          News
            NavigationDrawerItem(appSections[1]),
  //          Admission
            NavigationDrawerItem(appSections[2]),
  //          Department
            NavigationDrawerItem(appSections[3]),
  //          Training and Placement
            NavigationDrawerItem(appSections[4]),
  //          Contact Us
            NavigationDrawerItem(appSections[5]),
  
            Divider(
              color: Theme.of(context).brightness == Brightness.light
                  ? Colors.grey
                  : Colors.grey[600],
            ),
  
  //        Preferences
            InkWell(
              borderRadius: BorderRadius.circular(6),
              onTap: () {
                Navigator.of(context).pushNamed(SettingsScreen.routeName);
              },
              child: ListTile(
                leading: ClipRRect(
                  borderRadius: BorderRadius.circular(5),
                  child: Container(
                    padding: EdgeInsets.all(7),
                    child: Icon(
                      Icons.settings,
                      color: Theme.of(context).brightness == Brightness.light
                          ? Colors.black
                          : Colors.white,
                    ),
                  ),
                ),
                title: Text(
                  'Settings',
                  style: Theme.of(context).textTheme.bodyText2,
                ),
              ),
            ),
          ],
        ),
      );
    }
  }
  
  class NavigationDrawerItem extends StatelessWidget {
    final appSectionItem;
  
    NavigationDrawerItem(this.appSectionItem);
  
    @override
    Widget build(BuildContext context) {
      return InkWell(
        splashColor: appSectionItem['color'],
        borderRadius: BorderRadius.circular(6),
        onTap: () {
          Navigator.of(context).pushNamedAndRemoveUntil(
            appSectionItem['onTap'],
            ModalRoute.withName('/'),
          );
        },
        child: ListTile(
          leading: ClipRRect(
            borderRadius: BorderRadius.circular(5),
            child: Container(
              padding: EdgeInsets.all(7),
              color: appSectionItem['color'],
              child: Icon(
                appSectionItem['icon'],
                color: Colors.white,
              ),
            ),
          ),
          title: Text(
            appSectionItem['title'],
            style: Theme.of(context).textTheme.bodyText2,
          ),
        ),
      );
    }
  }
  
  </code></pre>
  
  <p><strong>themes.dart</strong></p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class Themes with ChangeNotifier {
    ThemeData _theme = ThemeData(
      brightness: Brightness.light,
  //    primaryColor: Colors.yellow,
  //    accentColor: Colors.amber,
      fontFamily: 'OpenSans',
      textTheme: TextTheme(
        headline5: TextStyle(
          fontFamily: 'OpenSans',
          fontSize: 16,
        ),
        headline6: TextStyle(
          fontFamily: 'OpenSans',
          fontWeight: FontWeight.bold,
          fontSize: 25,
        ),
        bodyText1: TextStyle(
          fontFamily: 'OpenSans',
          fontSize: 14,
        ),
        bodyText2: TextStyle(
          fontFamily: 'OpenSans',
          fontSize: 12,
        ),
        headline4: TextStyle(
          fontFamily: 'PlayfairDisplay',
          fontSize: 25,
          color: Colors.yellow[900],
        ),
      ),
    );
  
    getTheme() =&gt; _theme;
  
    changeTheme(brightness) {
      _theme = ThemeData(brightness: brightness);
      notifyListeners();
    }
  
  }
  </code></pre>
  
  <p><strong>settings screen</strong></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:provider/provider.dart';
  
  //providers
  import '../providers/themes.dart';
  
  class SettingsScreen extends StatefulWidget {
    static const routeName = 'settings_screen';
  
    @override
    _SettingsScreenState createState() =&gt; _SettingsScreenState();
  }
  
  class _SettingsScreenState extends State&lt;SettingsScreen&gt; {
    bool isSwitched = false;
  
    @override
    Widget build(BuildContext context) {
      Themes themeChanger = Provider.of&lt;Themes&gt;(context);
      return Scaffold(
        appBar: AppBar(
          title: Text(
            'Settings',
            style: Theme.of(context).textTheme.headline6,
          ),
          brightness: Theme.of(context).brightness,
          elevation: 3,
        ),
        body: Container(
          width: double.infinity,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: &lt;Widget&gt;[
              Padding(
                padding: EdgeInsets.fromLTRB(20, 10, 0, 10),
                child:
                    Text("Theme", style: Theme.of(context).textTheme.headline5),
              ),
              ListTile(
                title: Text(
                  "Overall look and feel of the app",
                  style: Theme.of(context).textTheme.bodyText1,
                ),
                subtitle: Text("Light/ Dark"),
                trailing: Switch(
                  value: isSwitched,
                  onChanged: (value) {
                    if (value) {
                      themeChanger.changeTheme(Brightness.dark);
                      setState(() {
                        isSwitched = value;
                      });
                      print(value);
                    } else {
                      themeChanger.changeTheme(Brightness.light);
                      setState(() {
                        isSwitched = value;
                      });
                      print(value);
                    }
                  },
                ),
              ),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>The other files have not been included.
  But when i navigate to any of them the Action button which should appear in the app bar does not.</p>