tlserver / flutter_map_location_marker

A flutter map plugin for displaying device current location.
https://pub.dev/packages/flutter_map_location_marker
BSD 3-Clause "New" or "Revised" License
102 stars 93 forks source link

added auto location permission request toggle support #78

Closed SalihCanBinboga closed 1 year ago

SalihCanBinboga commented 1 year ago

The parameter named [enabledLocationPermissionRequest] was added to prevent automatic location permission requests. In some cases, a dialog box may need to be displayed to request special location permission.

SalihCanBinboga commented 1 year ago

Hello @tlserver , If there is any issue related to this development, please let me know so that we can discuss it together 👋

tlserver commented 1 year ago

Accepted this PR with some modification in version 7.0.4 or 8.0.0-dev.2. To keep CurrentLocationLayer() simple, I only add requestPermissionCallback in LocationMarkerDataStreamFactory.defaultPositionStreamSource() since CurrentLocationLayer() can accept custom position stream. If position stream is provided, parameter for default stream have no effect. Here is a example code:

  const streamFactory = LocationMarkerDataStreamFactory();
  CurrentLocationLayer(
    positionStream: streamFactory.fromGeolocatorPositionStream(
      stream: streamFactory.defaultPositionStreamSource(
        requestPermissionCallback: null, // null to disable auto request or a callback to display dialog box or something else and request permission
      ),
    ),
  );

Thank you for contributing.