GradientStop.fromJson constructor

GradientStop.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory GradientStop.fromJson(Map<String, dynamic> json) {
  _requireExactKeys(json, const <String>{'offset', 'color'}, 'GradientStop');

  final offset = json['offset'];
  final color = json['color'];
  if (offset is! num || color is! int) {
    throw FormatException(
      'GradientStop requires numeric offset and integer color; '
      'got offset=$offset (${offset.runtimeType}), '
      'color=$color (${color.runtimeType})',
    );
  }

  return GradientStop(offset: offset.toDouble(), color: color);
}