decode static method Null safety

HeatmapLayer decode(
  1. String properties
)

Implementation

static HeatmapLayer decode(String properties) {
  var map = json.decode(properties);
  if (map["layout"] == null) {
    map["layout"] = {};
  }
  if (map["paint"] == null) {
    map["paint"] = {};
  }
  return HeatmapLayer(
    id: map["id"],
    sourceId: map["source"],
    sourceLayer: map["source-layer"],
    minZoom: map["minzoom"]?.toDouble(),
    maxZoom: map["maxzoom"]?.toDouble(),
    visibility: map["layout"]["visibility"] == null
        ? Visibility.VISIBLE
        : Visibility.values.firstWhere((e) => e
            .toString()
            .split('.')
            .last
            .toLowerCase()
            .contains(map["layout"]["visibility"])),
    heatmapColor: (map["paint"]["heatmap-color"] as List?)?.toRGBAInt(),
    heatmapIntensity: map["paint"]["heatmap-intensity"]?.toDouble(),
    heatmapOpacity: map["paint"]["heatmap-opacity"]?.toDouble(),
    heatmapRadius: map["paint"]["heatmap-radius"]?.toDouble(),
    heatmapWeight: map["paint"]["heatmap-weight"]?.toDouble(),
  );
}