5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutterをバージョンアップしたら'accentColor' is deprecated and shouldn't be used. Use colorScheme.secondary instead.

Last updated at Posted at 2022-02-08

main.dartで定義しているaccentColorがdeprecatedに

スクリーンショット 2022-02-08 20.16.41.png

VSCodeの機能で簡単に解決!

Quick Fix>Migrate to 'ColorScheme.secondary'を選択

スクリーンショット 2022-02-08 20.16.57.png

スクリーンショット 2022-02-08 20.17.23.png

これで以下のような形になるかと

main.dart
 child: MaterialApp(
        title: 'Title',
        theme: ThemeData(
          primaryColor: HexColor('F8EEF4'),
          colorScheme:
              ColorScheme.fromSwatch().copyWith(secondary: Colors.yellow[100]),
        ),

Theme.of(context).colorScheme.secondaryで使います:wink:

style: ElevatedButton.styleFrom(
   primary: Theme.of(context).colorScheme.secondary,
   onPrimary: Colors.black,
   shape: const StadiumBorder(),
 ),
5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?