Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ThemeData - deprecated title argument

Tags:

flutter

dart

I tried to find an answer for the question "how to correctly code the depreciated 'title' argument of ThemeData?" (I am following a tutorial). However I found the correct answer bewteen some comments in other topic. I leave the answer below for future references and an easy finding.

theme: new ThemeData(
  primaryTextTheme: TextTheme(
      title: TextStyle(
color: Colors.white,
))),

How to change text color of AppBar, icon color of FAB universally using theme?

Answer by eMarine: https://stackoverflow.com/users/1584407/emarine

like image 860
Joan Farfán Armas Avatar asked Apr 19 '20 22:04

Joan Farfán Armas


Video Answer


2 Answers

That is now deprecated, this giving message which itself says what to use

'title is the term used in the 2014 version of material design. The modern term is headline6. ' 'This feature was deprecated after v1.13.8.'

Example:

ThemeData(
          textTheme: ThemeData.light().textTheme.copyWith(
                headline6: GoogleFonts.lato(
                    color: _customColor,
                    fontWeight: FontWeight.normal),
              ),
      ),

Similarly,

Other parameters are also been deprecated. So, now we have to use the right ones which are mentioned below:

display4 => headline1;
display3 => headline2;
display2 => headline3;
display1 => headline4;
headline => headline5;
title    => headline6;
subhead  => subtitle1;
subtitle => subtitle2;
body2    => bodyText1;
body     => bodyText2;
like image 148
Jitesh Mohite Avatar answered Oct 04 '22 14:10

Jitesh Mohite


Replace 'title' for 'headline6':

theme: new ThemeData(
  primaryTextTheme: TextTheme(
      headline6: TextStyle(
color: Colors.white,
))),
like image 38
Joan Farfán Armas Avatar answered Oct 04 '22 14:10

Joan Farfán Armas