Flutter配置国际化库

1.在pubspec.yaml文件的dependencies下添加:

    flutter_localizations:

        sdk:flutter

2.在main.dart中导入头文件

    import 'package:flutter_localizations/flutter_localizations.dart';

3.在MaterialApp中赋值相应属性

    localizationsDelegates:[

        GlobalMaterialLocalizations.delegate,

        GlobalWidgetsLocalizations.delegate

    ],

    supportedLocales:[

        const Locale('zh','CH'),

        const Locale('en','US'),

    ]

你可能感兴趣的:(Flutter配置国际化库)