I have a PermissionsManager class, and I'm getting a "Do not use BuildContext across async gaps" for this particular method:
class PermissionsManager {
static Future<void> requestLocationPermission(BuildContext context) async {
final status = await Permission.location.request();
if (!status.isGranted) {
await showOpenSettingsDialog(context,
title: "Grant Location Access",
message:
"TODO");
}
}
}
I thought about splitting this into multiple functions, but then the caller needs to check the status, and based on the status call another method that will show this dialog box.
Is there a way to do this in the same method and handle this build context issue?