GetByText method
Implementation
@override
Future<dynamic> GetByText({String? text}) async {
Response returnResponse;
try {
Map<String, String> headers = {
HttpHeaders.contentTypeHeader: "application/json",
'User-Agent':
'Mozilla/5.0 (compatible; MyApp/1.0; +https://example.com)',
};
http: //geo.scirnd.xyz/search?q=Save%20the%20Children&format=json&accept-language=bn
String url = Configuration.GeoCodingSource.OSMConfig.NominatimURL!;
http.Response response = await http
.get(
Uri.parse(
"${url}search?q=$text&format=json&addressdetails=0&limit=10&polygon_svg=0&accept-language=en-US"),
headers: headers)
.timeout(
const Duration(seconds: 60),
onTimeout: () {
throw FetchDataException('Request timeout');
},
);
returnResponse = Response(
_returnResponse(response), response.statusCode, response.headers);
} on SocketException {
throw FetchDataException('No Internet connection');
}
return returnResponse;
}