Reputation: 1
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
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