第一步:配置flutter_localizations依赖 找到pubspec.yaml,配置flutter_localizations: flutter_localizations: sdk: flutter 第二步:导入国际化的包flutter_localizations.dart main.dart导入 import'package:flutter_localizations/flutter_localizations.dart'; 第三步,设置国际化 classMyApp extends StatelessWidget {constMyApp...
publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: sdk: ">=2.15.0 <3.0.0" dependency_overrides: analyzer: 5.2.0 build_resolvers: 2.1.0 dart_style: 2.2.4 ffi: ^1.2.0 dependencies: flutter_localizations: sdk: flutter flutter: sdk...
dev_dependencies:...flutter_localizations:sdk:flutter 执行命令: 代码语言:javascript 复制 flutter pubget Tool->Flutter Intl ->Initalize for the project: 成功后,在 pubspec.yaml末尾增加: 代码语言:javascript 复制 flutter_intl:enabled:true 在lib下生成generated 和 l10n generated包下的intl目录默认生成messag...
flutter_localizations: sdk: flutter # 权限申请 permission_handler: ^8.2.5 #图片加载组件 https://pub.dev/packages/extended_image/install extended_image: ^5.1.3 # 预览图片 photo_view: ^0.13.0 # 图片压缩 https://pub.flutter-io.cn/packages/flutter_image_compress flutter_image_compress: ^1.1.0...
# 实例1 直接写明约束版本,若该插件是发布在https://pub.dev/ 之上,IDE会直接在项目目录下执行`flutter packages get`来下载其插件的最新版本 transmogrify: # 实例2 该插件是在实例1的基础上进行延伸,其中`^1.4.0`的含义是约束了版本号,也就是在该项目中,需要使用1.4.0版本 ...
双击打开后,我们在里面添加上这两行即可: 为了方便大家 CV ,具体内容如下: export PUB_HO ...
创建localizations_delegate.dart。新建AppLocalizationsDelegate类继承LocalizationsDelegate,复写方法。 泛型指定为前面的AppStrings。 import'dart:async';import'package:flutter/widgets.dart';import'package:localization_demo/app_strings.dart';classAppLocalizationsDelegateextendsLocalizationsDelegate<AppStrings>{@overrideFutu...
$ flutterpubpubrun intl_translation:generate_from_arb--output-dir=lib/l10n \--no-use-deferred-loading lib/demo_localizations.dart lib/l10n/intl_*.arb 运行结果会出现 No @@localeor _locale field foundinintl_en,assuming'en'based on the file name.No @@localeor _locale field foundinintl_mess...
GlobalWidgetsLocalizations.delegate ], //new locale: Locale('zh',''), localeResolutionCallback:(Locale locale, Iterable<Locale> supportedLocales) { return Locale('zh',''); }, //new // ... ) 我们可以把Locale('zh','')作为一个变量即可 ...
运行flutter pub get指令后,自动生成的文件目录如下: 根据需要创建.arb文件编辑好内容后,保存文件就会在lib/language/generated目录下自动生成模板代码,下面以intl_zh.arb和intl_en.arb为例来修改。 修改项目入口的Widget 在mian()中的第一个Widget->build函数中添加如下3个地方。