showLocationDisclosureDialog function

Future<bool> showLocationDisclosureDialog()

Implementation

Future<bool> showLocationDisclosureDialog() async {
  return await showDialog(
        context: navigatorKey.currentState!.context,
        barrierDismissible: false, // User must tap button for close dialog
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text(localizedText('Location Permission Needed ')),
            content: Text(localizedText(
                'To enhance your experience, this app requests access to your location data to provide turn-by-turn directions, find nearby places, and offer personalized recommendations based on your current location.')),
            actions: <Widget>[
              TextButton(
                child: Text(localizedText('Decline')),
                onPressed: () {
                  Navigator.of(context).pop(false);
                },
              ),
              TextButton(
                child: Text(localizedText('Agree')),
                onPressed: () {
                  Navigator.of(context).pop(true);
                },
              ),
            ],
          );
        },
      ) ??
      false; // In case the dialog is dismissed by system back button
}