添加依赖
在pubspec.yaml依赖中添加
flutter_localizations:
sdk: flutter
引用
import 'package:flutter_localizations/flutter_localizations.dart';
配置
MaterialApp下
locale: Locale('en','US'),
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
Locale('en','US'),
Locale('zh','CN'),
],