Im very new to flutter, I have splash screen were loading will finish once the connection to the API success, after that I need to navigate to the next page, I want to check if the permission of the location was granted then go to home page, otherwise go to the page where the user need to click on a button to get the current location I don't know how to do this but the step of checking API connection was done, now the second step of checking the location, here is my code
Future<dynamic> getCurrentLocationData() async {
final status = await Permission.locationWhenInUse.status;
if (status == PermissionStatus.granted) {
return status;
} else if (status == PermissionStatus.denied) {
return status;
} else if (status == PermissionStatus.permanentlyDenied) {
return status;
}
}
Splash screen:
void loadData() {
_con.progress.addListener(() {
double progress = 0;
_con.progress.value.values.forEach((_progress) {
progress += _progress;
});
if (progress == 100) {
try {
//here need to check if the location permission was granted so go to the next page
Navigator.of(context).pushNamed('/homepage');
} catch (e) {}
}
});
}