LoginSignup
3
1

More than 1 year has passed since last update.

FlutterでInvalid constant value. が起きた時の対応方法

Posted at

下記ではエラーが起きないが

child: const SettingsList(
  lightTheme: SettingsThemeData(
    settingsListBackground: Colors.transparent,
  )
)

以下にするとTheme.of(context).colorscheme.backgroundのところでInvalid constant value. になる。

child: const SettingsList(
  lightTheme: SettingsThemeData(
    settingsListBackground: Theme.of(context).colorscheme.background,
  )
)

原因はTheme.of(context).colorscheme.backgroundのところではなく、const SettingsListの部分で、constを除外すれば解決する。

child: SettingsList(
  lightTheme: SettingsThemeData(
    settingsListBackground: Theme.of(context).colorscheme.background,
  )
)

以上

3
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
3
1