fromJson static method

GizmoColor? fromJson(
  1. Object? json
)

Implementation

static GizmoColor? fromJson(Object? json) {
  if (json is Map && json['bind'] is String) {
    return GizmoColor.bind(json['bind'] as String);
  }
  if (json is List && json.length >= 3 && json.every((c) => c is num)) {
    double channel(int i) => (json[i] as num).toDouble();
    return GizmoColor(
      channel(0),
      channel(1),
      channel(2),
      json.length > 3 ? channel(3) : 1,
    );
  }
  return null;
}