TextField等控件复制粘贴显示中文

image.png

1、修改pubspec.yaml

dependencies:
  #使用国际多语言支持,支持中文
  flutter_localizations:
    sdk: flutter

2、main.dart的 class MyApp中MaterialApp
加上localizationsDelegates和supportedLocales

import 'package:flutter_localizations/flutter_localizations.dart';

MaterialApp(
      ...  
      localizationsDelegates:const [ //复制粘贴控件自带字符串等显示中文
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: const [ //复制粘贴控件自带字符串等显示中文
        Locale('zh','CN'),
        Locale('en','US'),
      ],
    );

你可能感兴趣的:(TextField等控件复制粘贴显示中文)