栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

从右向左(RTL)颤动

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

从右向左(RTL)颤动

首先,您必须将

flutter_localizations
软件包添加到您的
pubspec.yml

dependencies:  flutter:    sdk: flutter  flutter_localizations:    sdk: flutter

现在您有两个选择:

1.在所有设备上强制使用语言环境(和方向)

- 方法1: 本地化

import 'package:flutter/material.dart';import 'package:flutter_localizations/flutter_localizations.dart';MaterialApp(  localizationsDelegates: [    GlobalMaterialLocalizations.delegate,    GlobalWidgetsLocalizations.delegate,  ],  supportedLocales: [    Locale("fa", "IR"), // OR Locale('ar', 'AE') OR Other RTL locales  ],  locale: Locale("fa", "IR") // OR Locale('ar', 'AE') OR Other RTL locales,  .  .  .);

- 方法2: 不进行本地化(如果使用此方法,则无需添加

flutter_localizations

MaterialApp(  .  .  .  builder: (context, child) {    return Directionality(      textDirection: TextDirection.rtl,      child: child,    );  },  .  .  .);

2.根据设备的区域设置设置布局方向(如果用户电话的区域设置是一种

RTL
语言,并且存在于中
supportedLocales
,则您的应用以
RTL
模式运行,否则,您的应用为
LTR

import 'package:flutter/material.dart';import 'package:flutter_localizations/flutter_localizations.dart';MaterialApp(  localizationsDelegates: [    GlobalMaterialLocalizations.delegate,    GlobalWidgetsLocalizations.delegate,  ],  supportedLocales: [    Locale("en", "US"),    Locale("fa", "IR"), // OR Locale('ar', 'AE') OR Other RTL locales  ],  .  .  .);

注意 :RTL语言在flutter中是:

[  'ar', // Arabic  'fa', // Farsi  'he', // Hebrew  'ps', // Pashto  'ur', // Urdu];


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/399892.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号