Flutter RTL AppBar 图标位置
Flutter RTL AppBar Icon postion
我要的是在 flutter 中的 appBar 中添加一个图标...我已经激活了本地化 属性 所以我的应用程序现在是 RTL
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
Locale("ar", "AR"), // OR Locale('ar', 'AE') OR Other RTL locales
],
locale: Locale("ar", "AR"), // OR Locale('ar', 'AE') OR Other RTL locales
...问题是右侧的抽屉菜单图标是正确的...但是当我在 appBar 的前导 属性 中添加图标时,它不会转到左侧...但是它取代了抽屉图标!!!
// 应用栏
appBar: new AppBar(
leading: Icon(Icons.person,),
title: new Text("الرئيسية",
style: new TextStyle(fontFamily: 'RPT Bold',
fontSize: 16.0,
color: Colors.amber
),
),
centerTitle: true,
iconTheme: new IconThemeData(color: Colors.amber),
),
此致
将 automaticallyImplyLeading
设置为 false :
appBar: new AppBar(
automaticallyImplyLeading: false,
leading: Icon(Icons.person,),
title: new Text("الرئيسية",
style: new TextStyle(fontFamily: 'RPT Bold',
fontSize: 16.0,
color: Colors.amber
),
),
centerTitle: true,
iconTheme: new IconThemeData(color: Colors.amber),
),
您可以用 Directionality
包装您的 Scaffold,并将文本方向设置为 RTL
。
这种方式不需要本地化 属性.
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.rtl,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('title'),
),
body: Container(child: Text('text',
),
),
),
);
}
我要的是在 flutter 中的 appBar 中添加一个图标...我已经激活了本地化 属性 所以我的应用程序现在是 RTL
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
Locale("ar", "AR"), // OR Locale('ar', 'AE') OR Other RTL locales
],
locale: Locale("ar", "AR"), // OR Locale('ar', 'AE') OR Other RTL locales
...问题是右侧的抽屉菜单图标是正确的...但是当我在 appBar 的前导 属性 中添加图标时,它不会转到左侧...但是它取代了抽屉图标!!!
// 应用栏
appBar: new AppBar(
leading: Icon(Icons.person,),
title: new Text("الرئيسية",
style: new TextStyle(fontFamily: 'RPT Bold',
fontSize: 16.0,
color: Colors.amber
),
),
centerTitle: true,
iconTheme: new IconThemeData(color: Colors.amber),
),
此致
将 automaticallyImplyLeading
设置为 false :
appBar: new AppBar(
automaticallyImplyLeading: false,
leading: Icon(Icons.person,),
title: new Text("الرئيسية",
style: new TextStyle(fontFamily: 'RPT Bold',
fontSize: 16.0,
color: Colors.amber
),
),
centerTitle: true,
iconTheme: new IconThemeData(color: Colors.amber),
),
您可以用 Directionality
包装您的 Scaffold,并将文本方向设置为 RTL
。
这种方式不需要本地化 属性.
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.rtl,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('title'),
),
body: Container(child: Text('text',
),
),
),
);
}