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.
48 lines
930 B
48 lines
930 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)
|
||
|
return [
|
||
|
CityModel(
|
||
|
code: code,
|
||
|
name: provincesData[code] ?? citiesData[code] ?? '',
|
||
|
)
|
||
|
];
|
||
|
return temp.entries
|
||
|
.map((e) => CityModel(
|
||
|
code: e.key,
|
||
|
name: e.value['name'],
|
||
|
))
|
||
|
.toList();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class ProvinceModel {
|
||
|
String code;
|
||
|
String name;
|
||
|
ProvinceModel({
|
||
|
this.code,
|
||
|
this.name,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
class CityModel {
|
||
|
String code;
|
||
|
String name;
|
||
|
CityModel({
|
||
|
this.code,
|
||
|
this.name,
|
||
|
});
|
||
|
}
|