Q: pushReplacementNamed doesn't work correctly on Drawer I'm a beginner on flutter and I'm making an APP but I have this problem :
In the main, I write this code :
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider.value(
          value: ImgProvider(),
        ), // create the provider of images
        ChangeNotifierProvider.value(
          value: Saved(),
        ), // create the provider of Saved
      ],
      child: MaterialApp(
        title: 'HTrip',
        theme: ThemeData(
          primarySwatch: Colors.green,
          accentColor: Colors.yellowAccent,
        ),
        home: SelectionPages(),
        routes: {
          '/saved'  :   (context) => SavedScreen(),
        }, // define the main page to be displayed
      ),
    );
  }
}

and In the SelectionPages()  , I wrote this :
drawer: Account(),

and In the Account() , I wrote this :
class Account extends StatelessWidget {
  Account();
  @override
  Widget build(BuildContext context) {
    final savedItem = Provider.of<Saved>(context);
    return Drawer(
          child: Column(
            children: <Widget>[
              AppBar(
          title: Text("Account"),
          automaticallyImplyLeading: false,
          centerTitle: true,
        ),
        Divider(),
        ListTile(
                leading: Icon(Icons.sd_card),
                title: Text("Saved"),
                onTap: () {
                  debugPrint("Hello button is clicked");
                  Navigator.of(context).pushReplacementNamed('/saved');
                  },
                // dense: true,
                trailing: Chip(
                  label: Text('${savedItem.savedCount}'),
                  labelStyle: TextStyle(color: Theme.of(context).primaryColor),
                ),
                //  enabled: true,
              )
            ]
          )
    );
  }
}

and In SavedScreen(), I wrote this:
class SavedScreen extends StatefulWidget {
  //static const routeName = '/Saved';

  @override
  _SavedScreenState createState() => _SavedScreenState();
}

class _SavedScreenState extends State<SavedScreen> {
  @override
  Widget build(BuildContext context) {
    final savedItem = Provider.of<Saved>(context);
    return Scaffold(
      appBar: AppBar(title: Text("Saved")),
      body: Column(
        children: <Widget>[
          Card(
            margin: const EdgeInsets.all(15),
            child: Padding(
              padding: const EdgeInsets.all(8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    Text(
                      'Saved item',
                      style: TextStyle(fontSize: 20),
                    ),
                    SizedBox(width: 10),
                    Spacer(), // to take all the empty space available in this place
                    Chip(
                      label: Text('${savedItem.savedCount}'),
                    ),
                    FlatButton(onPressed: () {}, child: Text("See all")),
                  ]),
            ),
          ),
          Expanded(
            child: Card(
              child: ImgSavedGridView(),
            ),
          ),
        ],
      ),
    );
  }
}

But when I run the App and I click on "Saved" ( where I run this "Navigator.of(context).pushReplacementNamed('/saved');") I got this error :
════════════════════════════════════════════════════════════════════════════════
I/flutter (27612): Hello button is clicked

════════ Exception caught by gesture ═══════════════════════════════════════════
Could not find a generator for route RouteSettings("/saved", null) in the _WidgetsAppState.
════════════════════════════════════════════════════════════════════════════════

PS : when I changed "Navigator.of(context).pushReplacementNamed('/saved');" to "Navigator.of(context).pushReplacementNamed('/');". it go to home page with no problem 
please Help me! 
I'm here for any clarification.
Thanks 

A: As from our discussion, you are using MaterialApp widget in SelectionPages also where you didn't define routing, but navigator look for routing over their.
Just remove MaterialApp widget in SelectionPages will solve your issue.
