loadAddressData static method

Future<List<AddressProvince>> loadAddressData(
  1. BuildContext context
)

Implementation

static Future<List<AddressProvince>> loadAddressData (
    BuildContext context) async {

  if (_provinces.isNotEmpty) {
    return _provinces;
  }
  var address = await rootBundle.loadString('packages/fl_address_picker/assets/address.json');
  var data = json.decode(address);
    var provinces = <AddressProvince>[];
    if (data is List) {
      for (var v in data) {
        var province = AddressProvince.fromJson(v);
        _provinceMap[province.provinceId!] = province;
        provinces.add(province);
      }
      _provinces = provinces;
      return _provinces;
    }
    return <AddressProvince>[];
}