{"id":13806194,"url":"https://github.com/igaurab/user_location_plugin","last_synced_at":"2025-10-23T01:25:46.370Z","repository":{"id":49999349,"uuid":"212739213","full_name":"igaurab/user_location_plugin","owner":"igaurab","description":"A plugin for FlutterMap to show user location and handle location permissions.","archived":true,"fork":false,"pushed_at":"2021-06-12T16:32:42.000Z","size":20287,"stargazers_count":47,"open_issues_count":19,"forks_count":75,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-21T15:46:40.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igaurab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-04T05:01:16.000Z","updated_at":"2024-06-21T15:46:40.206Z","dependencies_parsed_at":"2022-09-10T00:40:32.310Z","dependency_job_id":null,"html_url":"https://github.com/igaurab/user_location_plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igaurab%2Fuser_location_plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igaurab%2Fuser_location_plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igaurab%2Fuser_location_plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igaurab%2Fuser_location_plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igaurab","download_url":"https://codeload.github.com/igaurab/user_location_plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213870459,"owners_count":15650178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:01:08.719Z","updated_at":"2025-10-23T01:25:45.364Z","avatar_url":"https://github.com/igaurab.png","language":"Dart","readme":"# user_location\n\n[![pub package](https://img.shields.io/pub/v/user_location.svg)](https://pub.dartlang.org/packages/user_location) ![travis](https://api.travis-ci.com/lpongetti/flutter_map_marker_cluster.svg?branch=master) [![Codemagic build status](https://api.codemagic.io/apps/5e7057c82c964659341b9932/5e7057c82c964659341b9931/status_badge.svg)](https://codemagic.io/apps/5e7057c82c964659341b9932/5e7057c82c964659341b9931/latest_build)\n\n\n\nA plugin for [FlutterMap](https://github.com/johnpryan/flutter_map)  package to handle and plot the current user location\n\n\n\u003cdiv style=\"text-align: center\"\u003e\u003ctable\u003e\u003ctr\u003e\n  \u003ctd style=\"text-align: center\"\u003e\n  \u003ca href=\"https://github.com/igaurab/UserLocationPlugin/blob/master/example.gif\"\u003e\n    \u003cimg src=\"https://github.com/igaurab/UserLocationPlugin/blob/master/example.gif\" width=\"200\"/\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\u003c/table\u003e\u003c/div\u003e\n\n## Usage\n\nAdd flutter_map and  user_location to your pubspec.yaml :\n\n```yaml\ndependencies:\n  flutter_map: any\n  user_location:\n    git:\n      url: https://github.com/igaurab/user_location_plugin.git\n```\n\n\n\nUpdate your `gradle.properties` file with this:\n\n```\nandroid.enableJetifier=true\nandroid.useAndroidX=true\norg.gradle.jvmargs=-Xmx1536M\n```\n\n\n\nAlso make sure that you have added those dependencies in your build.gradle:\n\n```\n  dependencies {\n      classpath 'com.android.tools.build:gradle:3.3.0'\n      classpath 'com.google.gms:google-services:4.2.0'\n  }\n  compileSdkVersion 28\n```\n\n## Getting Started \n\n### Android \n\nIn order to use this plugin in Android, you have to add this permission in `AndroidManifest.xml` :\n\n```xml\n\u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /\u003e\n```\n\nPermission check for Android 6+ was added.\n\n### iOS\n* Note: I have not tested the plugin in ios\n\nOn iOS you'll need to add the NSLocationWhenInUseUsageDescription to your Info.plist file in order to access the device's location. Simply open your Info.plist file and add the following:\n\n```\n\u003ckey\u003eNSLocationWhenInUseUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app needs access to location when open.\u003c/string\u003e\n```\n\nIf you would like to access the device's location when your App is running in the background, you should also add the NSLocationAlwaysAndWhenInUseUsageDescription (if your App support iOS 10 or earlier you should also add the key NSLocationAlwaysUsageDescription) key to your Info.plist file:\n\n```\n\u003ckey\u003eNSLocationAlwaysUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app needs access to location when in the background.\u003c/string\u003e\n\u003ckey\u003eNSLocationAlwaysAndWhenInUseUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app needs access to location when open and in the background.\u003c/string\u003e\n```\n\n\n\n### Installation guide\n\n- Declare and initialize ```  MapController mapController = MapController(); List\u003cMarker\u003e markers = [];```\n- Add ` UserLocationPlugin()` to plugins\n- Add  `MarkerLayerOptions` and `UserLocationOptions` in `layers`\n\n\n### Sample code\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:user_location/user_location.dart';\nimport 'package:flutter_map/flutter_map.dart';\nimport 'package:latlong/latlong.dart';\n\nvoid main() =\u003e runApp(MyApp());\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      title: 'User Location Plugin Demo',\n      theme: ThemeData(\n        primarySwatch: Colors.blue,\n      ),\n      home: HomePage(),\n    );\n  }\n}\n\nclass HomePage extends StatelessWidget {\n  // ADD THIS\n  MapController mapController = MapController();\n  UserLocationOptions userLocationOptions;\n  // ADD THIS\n  List\u003cMarker\u003e markers = [];\n  @override\n  Widget build(BuildContext context) {\n    // You can use the userLocationOptions object to change the properties\n    // of UserLocationOptions in runtime\n    userLocationOptions = UserLocationOptions(\n                context: context,\n                mapController: mapController,\n                markers: markers,\n                );\n    return Scaffold(\n        appBar: AppBar(title: Text(\"User Location Plugin\")),\n        body: FlutterMap(\n          options: MapOptions(\n            center: LatLng(0,0),\n            zoom: 15.0,\n            plugins: [\n             // ADD THIS\n              UserLocationPlugin(),\n            ],\n          ),\n          layers: [\n            TileLayerOptions(\n              urlTemplate: \"https://api.tiles.mapbox.com/v4/\"\n                  \"{id}/{z}/{x}/{y}@2x.png?access_token={accessToken}\",\n              additionalOptions: {\n                'accessToken': '\u003caccess_token\u003e',\n                'id': 'mapbox.streets',\n              },\n            ),\n            // ADD THIS\n            MarkerLayerOptions(markers: markers),\n            // ADD THIS\n            userLocationOptions,\n          ],\n          // ADD THIS\n          mapController: mapController,\n        ));\n  }\n}\n```\n\n\n### Optional parameters\n* `markerWidget` overrides the default marker widget\n* `onLocationChange` is a callback function to get the current location of user. It's uses is defined in the example program.\n* `updateMapLocationOnPositionChange` moves the map to the current location of the user if set to `true`\n* `showMoveToCurrentLocationFloatingActionButton` displays a floating action button at the bottom right of the screen which will redirect the user to their current location. You can also pass your own widget as FAB and control the position using options `fabBottom` and `fabRight` options.\n* `showHeading` is used to control whether or not to show heading in the marker widget\n* `zoomToCurrentLocationOnLoad` if true, zooms to the current location of the user with a zoom factor 17\n* `moveToCurrentLocationFloatingActionButton` is a widget when passed overrides the default floating action button. Default floating action button code: \n``` \nContainer(\n    decoration: BoxDecoration(\n    color: Colors.blueAccent,\n    borderRadius: BorderRadius.circular(20.0),\n    boxShadow: [\n        BoxShadow(color: Colors.grey, blurRadius: 10.0)\n        ]),\n    child: Icon(\n        Icons.my_location,\n        color: Colors.white,\n    ),\n)\n```\n* `locationUpdateInBackground` if `false`, the location update stream is paused if the app is in the background. Once the app is resumed the stream is resumed as well. Option can be useful to reduce the battery consumption while the app is running in the background. Default: `true`.\n\n* `locationUpdateIntervalMs` desired interval for a location updates, in milliseconds. Default: 1000 milliseconds.\n\n\n### Run the example\n\nSee the `example/` folder for a working example app.\n","funding_links":[],"categories":["Dart"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figaurab%2Fuser_location_plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figaurab%2Fuser_location_plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figaurab%2Fuser_location_plugin/lists"}