1.在pubspec.yaml文件的dependencies下添加:
? ? flutter_localizations:
? ? ? ? sdk:flutter
2.在main.dart中導(dǎo)入頭文件
? ? import 'package:flutter_localizations/flutter_localizations.dart';
3.在MaterialApp中賦值相應(yīng)屬性
? ? localizationsDelegates:[
????????GlobalMaterialLocalizations.delegate,
????????GlobalWidgetsLocalizations.delegate
????],
? ? supportedLocales:[
? ? ? ? const Locale('zh','CH'),
? ? ? ? const Locale('en','US'),
????]