decode static method

BackgroundLayer decode(
  1. String properties
)

Implementation

static BackgroundLayer decode(String properties) {
  var map = json.decode(properties);
  if (map["layout"] == null) {
    map["layout"] = {};
  }
  if (map["paint"] == null) {
    map["paint"] = {};
  }
  return BackgroundLayer(
    id: map["id"],
    minZoom: map["minzoom"]?.toDouble(),
    maxZoom: map["maxzoom"]?.toDouble(),
    slot: map["slot"],
    visibility: map["layout"]["visibility"] == null
        ? Visibility.VISIBLE
        : Visibility.values.firstWhere((e) => e.name
            .toLowerCase()
            .replaceAll("_", "-")
            .contains(map["layout"]["visibility"])),
    backgroundColor: (map["paint"]["background-color"] as List?)?.toRGBAInt(),
    backgroundEmissiveStrength: map["paint"]["background-emissive-strength"]
            is num?
        ? (map["paint"]["background-emissive-strength"] as num?)?.toDouble()
        : null,
    backgroundOpacity: map["paint"]["background-opacity"] is num?
        ? (map["paint"]["background-opacity"] as num?)?.toDouble()
        : null,
    backgroundPattern: map["paint"]["background-pattern"] is String?
        ? map["paint"]["background-pattern"] as String?
        : null,
  );
}