How do I get the values from the drawer navigation pops?
Navigation push reloaded the entire page, which did not match the behavior of draw close.
Is there any way to solve this problem?
class _MyHomePageState extends State<MyHomePage> {
String sampleText = "";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
endDrawer: DrawerPage(),
body: Center(child: Text("Text returned from drawer is here $sampleText")),
);
}
}
class DrawerPage extends StatefulWidget {
@override
State<DrawerPage> createState() => _DrawerPageState();
}
class _DrawerPageState extends State<DrawerPage> {
@override
Widget build(BuildContext context) {
return Drawer(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context, "some text");
setState(() {});
},
child: const Text("Back Home"),
),
);
}
}