2
1

"FlutterをアップグレードしたらAppBarが消えた"の対処法

Posted at

FlutterをアップグレードしたらAppBarが消えた?

AppleのPrivacy Manifest対応をするべく、色々ライブラリをアップグレードする中で、Flutterも3.19.0にアップグレードしました。すると、AppBarがなくなり、Floating Action Buttonも紫になってしまいました。あれれ。


20240413本来の色.png

アップグレード後
20240413アップグレード後.png

直し方

ThemeDataに useMaterial3: false を追加するだけで直りました。

main.dart
return MaterialApp(
      title: 'Yamori memo',
      theme: ThemeData(
        primarySwatch: AppColors.mainBackColorMaterial,
        appBarTheme: AppBarTheme(
          //略
          )),
        ),
        textTheme: GoogleFonts.kiwiMaruTextTheme(
          Theme.of(context).textTheme,
        ),
+        useMaterial3: false,
      ),

原因

3.10からの Material3対応 によって色が変わってしまったためのようです。

Flutterさんが推奨しているなら、Material Designに寄せたいですが、他に優先したいことがあるので、ひとまずこれでしのぎます。

参考

https://medium.com/flutter/whats-new-in-flutter-3-10-b21db2c38c73
https://zenn.dev/team_soda/articles/ee134cc5ff7368#colorscheme.fromimageprovider()
https://flutter.salon/flutter/material3color/
https://zenn.dev/enoiu/articles/6b754d37d5a272

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1