fontWeight property

FontWeight? get fontWeight

Returns the component's FontWeight.

Implementation

FontWeight? get fontWeight {
  if (this.node is! figma.Text) {
    return null;
  }

  final node = this.node as figma.Text;
  final weight = node.style?.fontWeight?.toInt();
  if (weight == null) return FontWeight.normal;

  return switch (weight) {
    100 => FontWeight.w100,
    200 => FontWeight.w200,
    300 => FontWeight.w300,
    400 => FontWeight.w400,
    500 => FontWeight.w500,
    600 => FontWeight.w600,
    700 => FontWeight.w700,
    800 => FontWeight.w800,
    900 => FontWeight.w900,
    _ => FontWeight.normal,
  };
}