Skip to content

[Bug]: Permission.locationAlways.request doesn't wait for selection in system dialog #1457

Open
@KrsticM

Description

@KrsticM

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

When calling await Permission.locationAlways.request() system dialog is shown but lib is not waiting for a selection, instead it just returns .denied.

Expected results

To wait for a selection in location permission system dialog.

Actual results

PermissionStatus.denied is returned right away.

Code sample

Code sample
import 'dart:async';
import 'package:permission_handler/permission_handler.dart';
import 'package:vegetation_manager/common/helper/location_permission_manager.dart';

final class LocationPermissionManagerImpl implements LocationPermissionManager {
  @override
  Future<bool> isLocationAlwaysAllowed() async {
    var locationAlwaysStatus = await Permission.locationAlways.status;

    if (!locationAlwaysStatus.isGranted) {
      final whenInUseStatus = await Permission.locationWhenInUse.request();

      if (whenInUseStatus.isGranted) {
        // Not waiting for user to choose option in dialog, instead returning .denied right away
        locationAlwaysStatus = await Permission.locationAlways.request();
        return locationAlwaysStatus.isGranted;
      }
      return false;
    }
    return true;
  }
}

Screenshots or video

Screenshots or video demonstration

[Upload media here]

Version

11.4.0

Flutter Doctor output

Doctor output
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.0, on macOS 15.3.1 24D70 darwin-arm64, locale en-RS)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.98.0)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions