flutter - 当我有机会定向性时,颤动抽屉汉堡图标不显示
问题描述
我正在尝试使我的应用程序 RTL,并且我希望抽屉位于右侧。我设法从正确的方向打开它,但汉堡菜单图标消失了。
这是制作布局的代码rtl
:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter task',
home: Directionality(
textDirection: TextDirection.rtl,
child: new MyHomePage()
),
);
}
}`
这是我的抽屉:
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')
],
),
),
我错过了什么?
解决方案
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: (){
},
),
]
)
),
);
}
}
推荐阅读
- javascript - 如何在日期选择器中设置最大日期?
- php - 如何使用 SerciceManager 在 Zend/MVC 中启动应用程序
- java - 有没有办法从多个数组中创建一个具有属性的对象?
- postgresql - PostgreSQL 中窗口函数的最佳实践
- docker - 在 Windows 中使用 Docker Compose 运行 Kafka 的问题
- google-cloud-platform - 如何将 terraform 文件转换为在 vSphere 而不是 GCP 中配置/创建虚拟机?
- node.js - 从 Express 端点下载 zip 存档
- c++ - 使用 MSVC 编译时 msdpb* 文件的正确用法是什么
- ios - IOS 应用程序上的一次性密码 - 建议未出现在键盘上方
- python - 我可以在 SQL Server Management Studio 上安排 python 脚本吗?