[Flutter]AppBarのforegroundColorを使うには?

Flutter

どうも、ちょげ(@chogetarou)です。

AppBarの引数「foregroundColor」で色を指定しても、何も変化がない。

そういう人に向けて、AppBarのforegroundColorを使う方法を解説します。

スポンサーリンク

方法

        appBar: AppBar(
          foregroundColor: Colors.orange,
          backwardsCompatibility: false,
          title: Text('Sample'),
        ),

まず、foregroundColorに色を指定します。

そして、引数「backwardsCompatibility」に「false」を指定します。

これで「foregroundColor」が使えるようになります。

backwardCompatibilityは、デフォルトの設定情報を使うかを指定する引数です。

この引数を「false」にしなければ、「foregroundColor」ではなくデフォルトの設定が使われます。

なので、foregroundColorを使うために「backwardCompatibility」に「false」を指定するのです。

コメント

タイトルとURLをコピーしました