Area constructor

Area({
  1. double? size,
  2. double? flex,
  3. double? min,
  4. double? max,
  5. dynamic id,
  6. dynamic data,
  7. AreaWidgetBuilder? builder,
})

Implementation

Area(
    {double? size,
    double? flex,
    double? min,
    double? max,
    dynamic id,
    this.data,
    this.builder})
    : this.id = id != null ? id : _AreaId(),
      _size = size,
      _flex = flex,
      _min = min,
      _max = max {
  if (size != null && flex != null) {
    throw ArgumentError('Cannot provide both a size and a flex.');
  }
  NumUtil.validateDouble('size', size);
  NumUtil.validateDouble('flex', flex);
  NumUtil.validateDouble('min', min);
  NumUtil.validateDouble('max', max);
  if (size == null && flex == null) {
    _flex = 1;
  }
  if (min != null && max != null && max < min) {
    throw ArgumentError('The max needs to be greater than min.');
  }
  if (_flex != null) {
    if (min != null) {
      _flex = math.max(_flex!, min);
    }
    if (max != null) {
      _flex = math.min(_flex!, max);
    }
  } else if (_size != null) {
    if (min != null) {
      _size = math.max(_size!, min);
    }
    if (max != null) {
      _size = math.min(_size!, max);
    }
  }
}