场景: 在使用 TextField 表单组件时,长按表单的 复制\粘贴 功能时英文提示, 下面的示例将其变为中文
使用第三方插件 flutter_localizations
在 main.dart 中配置
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';
import 'app/routes/app_pages.dart';
void main()async {
// await Get.putAsync(() => TranslationService());
// Get.updateLocale(Locale('zh', 'CN')); // 设置默认本地化语言为中文
runApp(
GetMaterialApp(
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales:const [
Locale('zh','CN'),
Locale('en','US'),
],
title: "Application",
initialRoute: AppPages.INITIAL,
getPages: AppPages.routes,
),
);
}