Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 639 Vote(s) - 3.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
accentColor is deprecated and shouldn't be used

#1
The `accentColor` in `ThemeData` was deprecated.

What to use then in `ThemeData`?

theme: ThemeData(
brightness: Brightness.light,
primaryColor: kBaseColor,
accentColor: kBaseAccentColor, // 'accentColor' is deprecated and shouldn't be used

Reply

#2
As the deprecated message says:


```dart
///colorScheme.secondary
ThemeData(colorScheme: ColorScheme(secondary:Colors.white ),);
```
Reply

#3
Use the below code instead of **accentColor: kBaseAccentColor,**

colorScheme: ColorScheme.fromSwatch()
.copyWith(secondary: kBaseAccentColor),

**OR**

Do this in a simple way:
Click on Magic Bulb
[![enter image description here][1]][1]

Click on **Migrate to 'ColorScheme.secondary'** it will automatically be converted.

[![enter image description here][2]][2]


[1]:

[2]:
Reply

#4
`accentColor` is now replaced by `ColorScheme.secondary`.

* **Using new `ThemeData`:**

```dart
theme: ThemeData(
colorScheme: ColorScheme.fromSwatch().copyWith(
secondary: Colors.red, // Your accent color
),
)
```

* **Using existing `ThemeData`:**

```dart
final theme = ThemeData.dark();
```

You can use it as:

```dart
theme: theme.copyWith(
colorScheme: theme.colorScheme.copyWith(
secondary: Colors.red,
),
)
```
Reply

#5
Code before migration:


> Color myColor = Theme.of(context).accentColor;

Code after migration:

> Color myColor = Theme.of(context).colorScheme.secondary;
Reply

#6
Write this:

colorScheme: ColorScheme.fromSwatch()
.copyWith(secondary: kBaseAccentColor),

Then, use

> colorScheme.secondary

in place of

> accentColor

everywhere.
Reply

#7
you need to add a color scheme because accent color is deprecated.


body: const Center(child: const Text('BMI Calculator')),
floatingActionButton: Theme(
data: ThemeData(
colorScheme:
ColorScheme.fromSwatch().copyWith(secondary: Colors.white),
),
child: FloatingActionButton(
child: const Icon(
Icons.add,
),
onPressed: () {},
),
),
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through