SingleData.only constructor

SingleData.only(
  1. num data, {
  2. String? id,
  3. dynamic x,
})

Implementation

SingleData.only(num data, {String? id, this.x}) {
  if (data > 0) {
    up = data;
    down = 0;
  } else {
    up = 0;
    down = data;
  }
  if (id != null && id.isNotEmpty) {
    this.id = id;
  } else {
    this.id = const Uuid().v4().toString().replaceAll('-', '');
  }

  if (up < down) {
    throw FlutterError('maxData must more than minData');
  }

  if (x != null) {
    if (!(x is num || x is String)) {
      throw FlutterError('x only support num or string');
    }
  }
}