I got the following code:
theme: ThemeData(
primarySwatch: Colors.purple,
accentColor: Colors.deepOrange,
fontFamily: 'Lato',
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: CustomPageTransitionBuilder(),
TargetPlatform.iOS: CustomPageTransitionBuilder(),
},
),
),
And I know the accentColor
is deprecated, so because of that I get the following errors for these lines of code:
TextStyle( color: Theme.of(context).accentTextTheme.title.color,),
The getter 'title' isn't defined for the type 'TextTheme'. Try importing the library that defines 'title', correcting the name to the name of an existing getter, or defining a getter or field named 'title'.
TextStyle( color: Theme.of(context).primaryTextTheme.title.color,),
The getter 'title' isn't defined for the type 'TextTheme'. Try importing the library that defines 'title', correcting the name to the name of an existing getter, or defining a getter or field named 'title'.
How can I fix the issue and upgrade the codes?
Instead of
accentColor
, usecolorScheme
:Usage:
See also
If you're using Android Studio, you can right-click on the deprecated warning for it to fix the error: