LightGradient.fromJson constructor

LightGradient.fromJson(
  1. Map<String, dynamic> dataMap
)

Creates a LightGradient object from the JSON response to a GET request.

Implementation

factory LightGradient.fromJson(Map<String, dynamic> dataMap) {
  // Extract the points from the data map.
  List<LightColorXy> points = List<LightColorXy>.from(
    dataMap[ApiFields.points]?.map((point) => LightColorXy.fromJson(point)) ??
        [],
  );

  return LightGradient(
    points: points,
    mode: dataMap[ApiFields.mode] ?? "",
    modeValues: List<String>.from(dataMap[ApiFields.modeValues] ?? []),
  );
}