Ad
The Argument Type 'TextTheme' Can't Be Assigned To The Parameter Type 'Color'
I have a TabBar
in which I am using labelColor, I am trying to migrate accentTextTheme
, Currently my labelColor
is LIKE THIS:
labelColor:
Theme.of(context).accentTextTheme.headline4.color,
I trying to migrate accentTextTheme
like this from the flutter docs.
Code before migration:
TextStyle style = Theme.of(context).accentTextTheme.headline1;
Code after migration:
final ThemeData theme = Theme.of(context);
TextStyle style = theme.textTheme.headline1.copyWith(
color: theme.colorScheme.onSecondary,
),
but when I try to implement it I get this error:
The argument type 'TextTheme' can't be assigned to the parameter type 'Color'.
Is there any way to migrate this without getting this error?
Ad
Answer
labelColor
takes a Color
and you are providing TextStyle
,
final ThemeData theme = Theme.of(context);
TextStyle style = theme.textTheme.headline1!.copyWith(
color: theme.colorScheme.onSecondary,
);
return Scaffold(
body: Column(
children: [
TabBar( // just test for warring
labelColor: style.color,
tabs: [],
),
Text(
"asda",
style: style,
),
does it solve the issue?
Ad
source: stackoverflow.com
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?
Ad