getSearchAddress method
Implementation
dynamic getSearchAddress(String url,BuildContext context) async {
bool isConnected = await Internet.checkConnectivity();
if(isConnected)
{
try {
final client = HttpClient();
final uri = Uri.parse(url);
final request = await client.getUrl(uri);
final response = await request.close();
if (response.statusCode == HttpStatus.ok) {
final responseBody = await response.transform(const Utf8Decoder()).join();
return responseBody;
} else {
return null;
}
} on Exception catch (exc) {
debugPrint(exc.toString());
}
return null;
}
else
{
Fluttertoast.showToast(
msg: 'Internet is OFF',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: CssColors.popupTextColor,
textColor: Colors.white,
fontSize: 12.0
);
}
}