percent static method

double? percent(
  1. String value
)

A share from 0% to 100% or from 0 to 1, as a number from 0 to 1 (12% and 0.12 are the same); null otherwise.

Implementation

static double? percent(String value) {
  final text = value.trim();
  final isPercent = text.endsWith('%');
  final number = ThemeValues.number(
    isPercent ? text.substring(0, text.length - 1) : text,
  );
  if (number == null || number.isNaN || number.isInfinite) {
    return null;
  }
  final share = isPercent ? number / 100 : number;
  return share < 0 || share > 1 ? null : share;
}