Flutterを用いてandroidAppの色を設定しようと思ってなぜか詰まったので、書き残します。
■概要(課題)
appBarの色を調整したくて以下のドキュメントからprimaryColorを使えば編集できるらしいのでやってみた
ThemeData class - material library - Dart API
API docs for the ThemeData class from the material library, for the Dart programming language.

MaterialApp(
theme: ThemeData(
primaryColor: Color(0xFF012345), //012345が任意の16進数詳細は上記のColorに書いてある
),
home: MyHomePage(),
);
しかし、出力してみると以下、本来ならappBarが黒に近い色になるはず。

■解決策 appBarThemeを使う
AppBarTheme class - material library - Dart API
API docs for the AppBarTheme class from the material library, for the Dart programming language.
class ClassName extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
brightness: Brightness.dark, //これは余計なコード遊んでるだけ
appBarTheme: AppBarTheme(
backgroundColor: Color(0xFF012345), //ココの3行で指定しています。
),
scaffoldBackgroundColor: Color(0xFF123456), //これは余計なコード遊んでるだけ
// 他のダークモードの設定もここに追加できます。
),
home: InputPage(),
);
}
}

勉強中なので、なんでこれでできるのかは説明しきれませんが、
恐らく、課題になっていたのはデフォルト設定が優位にあっただけで、
appBarThemeを使うことで有効になる理由はわかりません。(なんとなく感覚としてわかるんだけど、言語化できないのでわからん)
何かわかれば、更新すると思います。以上!


コメント