Eli Front
Eli Front

Reputation: 775

How to set a custom FontWeight value in Flutter

When setting font weights in Flutter I usually use preset values such as FontWeight.normal or FontWeight.w500. In my current situation I need to set a custom FontWeight. How can I set the font weight to 350 (Book)? Maybe there is a constructor I don't know about.

It would look something like this:

Text(
    'some text',
    style: TextStyle(
        fontWeight: FontWeight.w300, //but instead of 300 it's 350
    )
)

Thanks!

Upvotes: 3

Views: 9520

Answers (2)

Lohit Rachakonda
Lohit Rachakonda

Reputation: 64

FontWeight is a const parameter. A list of all the font weights. const [w100, w200, w300, w400, w500, w600, w700, w800, w900]

You could use FontWeight.w200 along with fontStyle:FontStyle.bold,

Just give it a try. Let me know if it works.

Upvotes: 1

Junsu Cho
Junsu Cho

Reputation: 854

Text(
  'some text',
   style: TextStyle(
    fontWeight: FontWeight.lerp(FontWeight.w300, FontWeight.w400, 0.5), //but instead of 300 it's 350
    )
)

Upvotes: 3

Related Questions