如何在Flutter中将系统剪贴板文本(复制,粘贴等)的语言更改为中文?

时间:2018-09-27 11:59:47

标签: flutter flutter-layout flutter-dependencies

我尝试了这个,但是似乎不起作用:

new MaterialApp(
  title: 'Mian',
  localizationsDelegates: [
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
  ],
  supportedLocales: [
    const Locale('zh','HK')
  ],

我想将粘贴更改为粘贴,选择全部以选择全部

enter image description here

1 个答案:

答案 0 :(得分:0)

  1. flutter_localizations添加到pubspec.yaml
dependencies:
  flutter:
    sdk: flutter

  flutter_localizations:
    sdk: flutter
  1. flutter_localizations导入main.dart
import 'package:flutter_localizations/flutter_localizations.dart';
  1. 使用supportedLocales
class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter',
      home: new HomePage(title: ''),
      localizationsDelegates: [                             
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        DefaultCupertinoLocalizations.delegate
      ],
      supportedLocales: [
        const Locale('zh','CH'),
      ],
    );
  }
}