You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansu_ui/lib/utils/city_util.dart

48 lines
937 B

4 years ago
import 'package:ansu_ui/utils/cities.dart';
class CityUtil {
static List<ProvinceModel> get provinceModel {
return provincesData.entries
.map((e) => ProvinceModel(
code: e.key,
name: e.value,
))
.toList();
}
static List<CityModel> getCityModelByCode(String? code) {
Map<String, dynamic>? temp = citiesData[code!];
if (temp?.entries.isEmpty ?? true)
4 years ago
return [
CityModel(
code: code,
name: provincesData[code] ?? citiesData[code] ?? '',
)
];
return temp!.entries
4 years ago
.map((e) => CityModel(
code: e.key,
name: e.value['name'],
))
.toList();
}
}
class ProvinceModel {
String? code;
String? name;
4 years ago
ProvinceModel({
this.code,
this.name,
});
}
class CityModel {
String? code;
String? name;
4 years ago
CityModel({
this.code,
this.name,
});
}