coiai Logo

This article is an English translation of the original Japanese post. Read the Japanese original →

[Flutter] primarySwatch: Colors.blue, Is Already Outdated — Welcome to the Era of ○○

May 11, 2025

Categories: Flutter · Tags: Flutter, プログラミング

In Flutter,

final ThemeData darkTheme = ThemeData(
  fontFamily: 'NotoSansJP',
  primarySwatch: Colors.blue,
);

using primarySwatch like this no longer works.

So what should you do instead?

As of now (May 2025), to change the overall color you need to use

final ThemeData darkTheme = ThemeData(
  fontFamily: 'NotoSansJP',
  colorScheme: ColorScheme.fromSeed (
    seedColor: Colors.blue,
    brightness: Brightness.dark,
    dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot
  ),
);

colorScheme like this.

For the values of each property, your best bet is the official documentation!

Default state

For configuring individual colors, the examples partway through the official documentation are incredibly clear. Definitely worth checking out.

References

https://api.flutter.dev/flutter/material/ColorScheme-class.html

https://api.flutter.dev/flutter/material/MaterialColor-class.html

[Flutter] primarySwatch: Colors.blue, Is Already Outdated — Welcome to the Era of ○○ | coiai Inc.