flutter drawer Hamburger icon is not showing when i chance Directionality
6,121
Wrap your home child widget with Directionality
using TextDirection.rtl
import 'package:flutter/material.dart';
class DrawerLayoutApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: "My Apps",
theme: new ThemeData(
fontFamily: "Vazir",
primaryColor: Color(0xff075e54),
accentColor: Color(0xff25d366),
primaryIconTheme: new IconThemeData(color: Colors.white)
),
home: new Directionality(textDirection: TextDirection.rtl, child: new DrawerLayoutAppBody())
);
}
}
class DrawerLayoutAppBody extends StatefulWidget {
@override
State<StatefulWidget> createState() => new DrawerLayoutAppBodyState();
}
class DrawerLayoutAppBodyState extends State<DrawerLayoutAppBody>{
TextStyle listTileTextStyle = new TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18
);
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("برنامه های من")
),
drawer: new Drawer(
child: new ListView(
children: <Widget>[
new Container(
height: 120,
child: new DrawerHeader(
padding: EdgeInsets.zero,
child: new Container(
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: <Color>[
Theme.of(context).primaryColor,
const Color(0xff05433c),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter
)
),
)
)
),
new ListTile(
leading: new Icon(Icons.map, color: Colors.black),
title: new Text(
'گوگل مپ',
style: listTileTextStyle
),
onTap: (){
},
),
]
)
),
);
}
}
Author by
Sarah
Updated on December 14, 2022Comments
-
Sarah over 1 year
I am trying to make my app RTL and I want the drawer to be on the right side. I managed to open it from the right direction but the hamburger menu icon disappeared.
This is code to make the layout
rtl
:class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter task', home: Directionality( textDirection: TextDirection.rtl, child: new MyHomePage() ), ); } }`
and this is my drawer :
drawer: new Container( constraints: new BoxConstraints.expand( width: MediaQuery .of(context) .size .width - 60, ), color: Colors.black.withOpacity(0.6), alignment: Alignment.center, child: new ListView( children: <Widget>[ Text('1'), Text('2') ], ), ),
What am I missing?
-
Aakash Kumar almost 5 yearsCan you send some code of the scaffold where you are using this drawer?
-
-
CopsOnRoad almost 5 yearsDon't pass any
child
toDrawer
and check if it is working. -
Sarah almost 5 yearsstill the same !