TiledMap.fromJson constructor

TiledMap.fromJson(
  1. Map<String, dynamic> json
)

Implementation

TiledMap.fromJson(Map<String, dynamic> json) {
  compressionLevel = json['compressionlevel'];
  height = json['height'];
  infinite = json['infinite'];
  if (json['layers'] != null) {
    layers = <MapLayer>[];
    json['layers'].forEach((v) {
      if (v['type'] == TypeLayer.tilelayer.getName()) {
        layers?.add(TileLayer.fromJson(v));
      } else if (v['type'] == TypeLayer.objectgroup.getName()) {
        layers?.add(ObjectGroup.fromJson(v));
      } else if (v['type'] == TypeLayer.imagelayer.getName()) {
        layers?.add(ImageLayer.fromJson(v));
      } else if (v['type'] == TypeLayer.group.getName()) {
        layers?.add(GroupLayer.fromJson(v));
      } else {
        layers?.add(MapLayer.fromJson(v));
      }
    });
  }
  nextLayerId = json['nextlayerid'];
  nextObjectId = json['nextobjectid'];
  orientation = json['orientation'];
  renderOrder = json['renderorder'];
  tiledVersion = json['tiledversion'];
  tileHeight = json['tileheight'];
  if (json['tilesets'] != null) {
    tileSets = <TileSetDetail>[];
    json['tilesets'].forEach((v) {
      tileSets?.add(new TileSetDetail.fromJson(v));
    });
  }
  tileWidth = json['tilewidth'];
  type = json['type'];
  version = double.tryParse(json['version'].toString()) ?? 0.0;
  width = json['width'];
  backgroundColor = json['backgroundcolor'];
  hexSideLength = json['hexsidelength'];
  staggerAxis = json['staggeraxis'];
  staggerIndex = json['staggerindex'];
}