2

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 ?

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.