Trying to implement a side drawer in a new app, I could render it but it covers the whole screen, here is how I set it:
the home page:
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home'),
),
drawer: SideDrawer(),
body: Center(
child: Text('Home page'),
),
);
}
}
the drawer widget in a separate file:
class SideDrawer extends StatelessWidget {
const SideDrawer({Key key, this.user}) : super(key: key);
final FirebaseUser user;
@override
Widget build(BuildContext context) {
return new SizedBox(
width: MediaQuery.of(context).size.width * 0.85,
child: Drawer(
child: new ListView(
children: <Widget>[
new DrawerHeader(
child: new Text("DRAWER HEADER.."),
decoration: new BoxDecoration(color: Colors.orange),
),
new ListTile(
title: new Text("Item => 1"),
onTap: () {
Navigator.pop(context);
Navigator.push(context,
new MaterialPageRoute(builder: (context) => new HomePage()));
},
),
],
)),
);
}
}
Update: The drawer should get user details from the login page, and I guess that the issue here is related to the fact that the drawer is called from a separate home scaffold, that's why at the beginning it covers its whole area despite 85% of the screen area is set in the code.
I have tried this solution too but didn't work, any suggestion ?

