I tried to extract my app bar and drawer into a separate stateless widgets (elrDrawer.dart). but when i click on the hamburger icon (in startUp.dart), the drawer opens behind the body. can somebody tell me why this is happening and how to solve it? appreciate the help <3
class Startup extends StatefulWidget {
@override
_StartupState createState() => _StartupState();
}
class _StartupState extends State<Startup> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: ElrDrawer(),
drawer: ElrDrawer(),
body: Container(
color: Colors.pink,
height: double.infinity,
width: double.infinity,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
startUpCard('Order', Order()),
startUpCard('History', History()),
startUpCard('Menu', Menu()),
startUpCard('FAQ', FAQ()),
],
),
),
),
);
}
^ startup.dart
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// automaticallyImplyLeading: false,
title: Text('title'),
actions: <Widget>[
Padding(
padding: EdgeInsets.all(10),
),
],
),
drawer: Container(
child: Drawer(
child: ListView(
children: [
SizedBox(
height: 300,
child: DrawerHeader(
// padding: EdgeInsets.zero,
child: Stack(
alignment: Alignment.bottomLeft,
// fit: StackFit.passthrough,
children: [
Opacity(
opacity: 1,
child: Image.asset(
'assets/images/magik.png',
),
),
],
),
),
),
drawerListTile(context, 'HISTORY', History()),
divider(),
drawerListTile(context, 'MENU', Menu()),
divider(),
drawerListTile(context, 'FAQ', FAQ()),
divider(),
drawerListTile(context, 'DASHBOARD', null),
divider(),
drawerListTile(context, 'LOGOUT', null),
divider(),
],
),
),
),
body: Container(
color: Colors.brown,
),
);
}
^elrDrawer.dart
startUp.dart before click hamburger icon
startUp.dart after click hamburger icon with the drawer only appearing in the appBar