1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter Location Web hasPermission() throwing TypeError

Discussão em 'Mobile' iniciado por Stack, Novembro 7, 2024 às 10:52.

  1. Stack

    Stack Membro Participativo

    This method per the documentation seems to work perfectly on iOS and Android but on Web I'm getting a random type error within the package.

    Here's my code:

    _serviceEnabled = await location.serviceEnabled();
    if (!_serviceEnabled) {
    _serviceEnabled = await location.requestService();
    if (!_serviceEnabled) {
    StackTrace.current
    .printWithInfo('No User Location Available: Services Not Enabled!');
    streamController.add(_initialFocusLocation);
    return;
    }
    }

    // try {
    _permissionGranted = await location.hasPermission();
    if (_permissionGranted == PermissionStatus.denied ||
    _permissionGranted == PermissionStatus.deniedForever) {
    _permissionGranted = await location.requestPermission();
    if (_permissionGranted != PermissionStatus.granted ||
    _permissionGranted != PermissionStatus.grantedLimited) {
    StackTrace.current
    .printWithInfo('No User Location Available: Permission Not Granted!');
    streamController.add(_initialFocusLocation);
    return;
    }
    }


    The error is thrown at location.hasPermission()

    TypeError: Failed to execute 'query' on 'Permissions': Failed to read the 'name' property from 'PermissionDescriptor': Required member is undefined.
    packages/location_web/location_web.dart 60:15 hasPermission


    Does anyone have this working on the web?

    Packages and versions: location: 6.0.2 flutter: 3.22.2 dart: 3.4.3

    Continue reading...

Compartilhe esta Página