When using the Flutter Scaffold.Drawer - is it possible to have the links in the Drawer change the content (Scaffold.body) on the page?
Similarly to having links in
You can use this for body of Scaffold:
body: _getDrawerItemWidget(_selectedDrawerIndex));
and then in the main or state class do like so:
class HomePageState extends State {
int _selectedDrawerIndex = 0;
_getDrawerItemWidget(int pos) {
switch (pos) {
case 0:
return new MainFragment();
case 1:
return new CardMgmt();
}
}
}
CardMgmt and other classes in switch case have their own build method that will return a Widget and it will be place in body of your scaffold. Also they can be in the same dart file or even another file.
But I have another problem:
What to do if instead of drawer items, we have a button in another class like CardMgmt and we want it to return a Widget and update page?