parseFontWeight static method

FontWeight parseFontWeight(
  1. String weight
)

Implementation

static FontWeight parseFontWeight(String weight) {
  var fontWeight = FontWeight.normal;
  if ("bold" == weight) {
    fontWeight = FontWeight.bold;
  } else if ("normal" == weight) {
    fontWeight = FontWeight.normal;
  } else {
    var fontWeightNumeric = _parseArgument(weight);
    if (fontWeightNumeric != -1) {
      if (fontWeightNumeric <= 100) {
        fontWeight = FontWeight.w100;
      } else if (fontWeightNumeric <= 200) {
        fontWeight = FontWeight.w200;
      } else if (fontWeightNumeric <= 300) {
        fontWeight = FontWeight.w300;
      } else if (fontWeightNumeric <= 400) {
        fontWeight = FontWeight.w400;
      } else if (fontWeightNumeric <= 500) {
        fontWeight = FontWeight.w500;
      } else if (fontWeightNumeric <= 600) {
        fontWeight = FontWeight.w600;
      } else if (fontWeightNumeric <= 700) {
        fontWeight = FontWeight.w700;
      } else if (fontWeightNumeric <= 800) {
        fontWeight = FontWeight.w800;
      } else {
        fontWeight = FontWeight.w900;
      }
    }
  }

  return fontWeight;
}