searchDatas function

Future<List<MakerInfo>> searchDatas(
  1. Client client,
  2. String keyword
)

Implementation

Future<List<MakerInfo>> searchDatas(http.Client client, String keyword) async {
  List<MakerInfo> results = [];
  if(keyword.isNotEmpty) {
  final response = await client
      .get(Uri.parse('https://mapi.darkvn.net/searchbytext?address='+keyword+'&token=Ksdjfxxxx_SMx_v1'));
print('Routing Coords:${Uri.parse('https://mapi.darkvn.net/searchbytext?address='+keyword+'&token=Ksdjfxxxx_SMx_v1')}');
    var data = jsonDecode(response.body);

    if(data.length >0) {
      Random random = new Random();
      for(int i = 0; i <data.length ; i++) {
results.add(MakerInfo(
      type: 'spoint',
      id: random.nextInt(100000000),
      lat: data[i]['lat'] as double,
      lng: data[i]['lng'] as double,
      name: data[i]['name'] as String,
      address: data[i]['type'] != null && !data[i]['type']?.isEmpty ? data[i]['type'].join(", ") as String : '',
      phone: '',
      img: '',
      fax: '',
      email: '',
      routingInfo: null,
));
      }

    }
    }
    return results;

}