Flutter常见开发问题总结《持续更新》

Flutter沉浸式状态栏

void main() {
  runApp(MyApp());
  if (Platform.isAndroid) {
    SystemUiOverlayStyle systemUiOverlayStyle =
        SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

Flutter修改状态栏字体颜色

使用AnnotatedRegion包裹Scaffold,可以使得状态栏颜色改变,有dark和light两种

@override
  Widget build(BuildContext context) {
  return AnnotatedRegion(
    value: SystemUiOverlayStyle.light,
    child: Material(child:Scaffold(),),);
}

Flutter修改状态栏字体颜色

appBar: AppBar(
    title: Text('input'),
    brightness: Brightness.dark // Brightness.light
    )

Flutter处理国际化多语言

  1. 首先要安装插件:Flutter i18n,建立res/values/strings_en.arb文件 编写键值对的JSON即可
  2. 修改main.dart文件如下:

Flutter intl 实现国际化

1.添加依赖

dependencies:
  intl: ^0.16.1
  flutter_localizations:
    sdk: flutter

2.Android Studio 安装插件 Flutter Intl


Flutter常见开发问题总结《持续更新》_第1张图片
QQ截图20200722104944.png

3.初始化国际化香蜜


Flutter常见开发问题总结《持续更新》_第2张图片
QQ截图20200722105023.png

4.配置工程
      localizationsDelegates: const [
        S.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate
      ],
      locale: Locale("en"),
      supportedLocales: S.delegate.supportedLocales,

你可能感兴趣的:(Flutter常见开发问题总结《持续更新》)