The fighter khaled
The fighter khaled

Reputation: 1

using colorScheme vs accent color

i know colorscheme is now instead of accent color and I want to use color scheme instyling Textbutton for example but when i use it in styling there is a problem in types different so I make a cast like that

itemBuilder: (ctx, index) => Card(
color: Theme.of(context).colorScheme as Color

, or

style: ElevatedButton.styleFrom(
                primary: Theme.of(context).colorScheme as Color) 

is that right or wrong ?

Upvotes: 0

Views: 55

Answers (1)

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63604

Theme.of(context).colorScheme provides list of color, you can't use like it where you need to pass single color.

To use primary color from colorScheme you n need to specify

 primary: Theme.of(context).colorScheme.primary,

More about ColorScheme

Upvotes: 1

Related Questions