of<T extends Dimen> static method

T of<T extends Dimen>(
  1. String name,
  2. Size size, [
  3. T? initial
])

Implementation

static T of<T extends Dimen>(String name, Size size, [T? initial]) {
  final device = i.device(size);
  final scaleFactor = device.fontScaleFactor;
  final x = _of(name)?.detect(device.type);
  if (x is ConstraintDimen) {
    return x.scale(scaleFactor) as T;
  } else if (x is SizeDimen) {
    return x.scale(scaleFactor) as T;
  } else if (x is WeightDimen) {
    return x.scale(scaleFactor) as T;
  } else if (initial != null) {
    return initial;
  }
  throw UnimplementedError("$T not initialized yet for $name");
}