LightGradientFull.fromJson constructor

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

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

Implementation

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

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