1

In VSCode, Flutter is complaining to me that "'accentColor' is deprecated and shouldn't be used. Use colorScheme.secondary instead. For more information, consult the migration guide at https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. This feature was deprecated after v2.3.0-0.1.pre.. Try replacing the use of the deprecated member with the replacement."

The migration guide suggests this :

Code before migration:

MaterialApp(
  theme: ThemeData(accentColor: myColor),
  // ...
);

Code after migration:

final ThemeData theme = ThemeData();
MaterialApp(
  theme: theme.copyWith(
    colorScheme: theme.colorScheme.copyWith(secondary: myColor),
  ),
  //...
)

So I made this change :

   Widget build(BuildContext context) {
+    final ThemeData theme = ThemeData();
     return MaterialApp(
       title: 'Title',
-      theme: ThemeData(
-        primaryColor: Color.fromRGBO(95, 53, 90, 1),
-        accentColor: Color.fromRGBO(76, 41, 71, 1)
+      theme: theme.copyWith(
+        colorScheme: theme.colorScheme.copyWith(
+          primary: Color.fromRGBO(95, 53, 90, 1),
+          secondary: Color.fromRGBO(76, 41, 71, 1),
         ),
+      ),
       home: MyApp()
     );
   }

But now my checkboxes and switches have changed from my primary colour to blue.

Can I still set the colour of my checkboxes in the theme ?

Turkey
  • 346
  • 4
  • 16
  • This answer can help you. https://stackoverflow.com/questions/69289005/accentcolor-is-deprecated-and-shouldnt-be-used – Hasib Akon Nov 18 '21 at 04:05

1 Answers1

1

The Checkbox, along with a few other widgets, still don't migrate to Material 3 scheme. There's already an open issue #104446. The pull request #97972 seems will fix this.

Currently, you can orerride toggleableActiveColor in ThemeData to achieve this.

Twisted Lullaby
  • 551
  • 1
  • 8
  • 20