3

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!

2 Answers 2

2
Text(
  'some text',
   style: TextStyle(
    fontWeight: FontWeight.lerp(FontWeight.w300, FontWeight.w400, 0.5), //but instead of 300 it's 350
    )
)
2
  • this is ends up just outputting FontWeight.w400
    – Eli Front
    Aug 10, 2020 at 2:32
  • 1
    Sorry, There is currently no way to implement it. There is no way to modify the font except by modifying the font itself and making it w400 to w350.
    – Junsu Cho
    Aug 10, 2020 at 3:10
1

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.