BMFSuggestAddrInfo.fromMap constructor Null safety

BMFSuggestAddrInfo.fromMap(
  1. Map map
)

map => BMFSuggestAddrInfo

Implementation

BMFSuggestAddrInfo.fromMap(Map map)
    : assert(
          map != null, // ignore: unnecessary_null_comparison
          'Construct a BMFSuggestAddrInfo,The parameter map cannot be null !') {
  if (map['startPoiList'] != null) {
    List<BMFPoiInfo> tmpStartPoiList = [];

    map['startPoiList'].forEach((v) {
      tmpStartPoiList.add(BMFPoiInfo.fromMap(v as Map));
    });
    startPoiList = tmpStartPoiList;
  }

  if (map['startCityList'] != null) {
    List<BMFCityListInfo> tmpStartCityList = [];

    map['startCityList'].forEach((v) {
      tmpStartCityList.add(BMFCityListInfo.fromMap(v as Map));
    });
    startCityList = tmpStartCityList;
  }

  if (map['endPoiList'] != null) {
    List<BMFPoiInfo> tmpEndPoiList = [];
    map['endPoiList'].forEach((v) {
      tmpEndPoiList.add(BMFPoiInfo.fromMap(v as Map));
    });
    endPoiList = tmpEndPoiList;
  }

  if (map['endCityList'] != null) {
    List<BMFCityListInfo> tmpEndCityList = [];
    map['endCityList'].forEach((v) {
      tmpEndCityList.add(BMFCityListInfo.fromMap(v as Map));
    });
    endCityList = tmpEndCityList;
  }

  if (map['wayPointPoiList'] != null) {
    List<List<BMFPoiInfo>> tmpWayPointPoiList = [];
    for (List item in (map['wayPointPoiList'] as List)) {
      List<BMFPoiInfo> list = [];
      for (var ite in item) {
        BMFPoiInfo info = BMFPoiInfo.fromMap(ite as Map);
        list.add(info);
      }
      tmpWayPointPoiList.add(list);
    }
    wayPointPoiList = tmpWayPointPoiList;
  }

  if (map['wayPointCityList'] != null) {
    List<List<BMFCityListInfo>> tmpWayPointCityList = [];
    for (List item in (map['wayPointCityList'] as List)) {
      List<BMFCityListInfo> list = [];
      for (var ite in item) {
        BMFCityListInfo cityListInfo = BMFCityListInfo.fromMap(ite as Map);
        list.add(cityListInfo);
      }
      tmpWayPointCityList.add(list);
    }
    wayPointCityList = tmpWayPointCityList;
  }
}