{"id":15294753,"url":"https://github.com/itzmeanjan/locate","last_synced_at":"2025-04-13T14:54:14.531Z","repository":{"id":56834168,"uuid":"174199492","full_name":"itzmeanjan/locate","owner":"itzmeanjan","description":"A Flutter plugin to fetch GPS/ Network based Location Data Feed on Android, made with \u003c3","archived":false,"fork":false,"pushed_at":"2020-07-31T05:25:17.000Z","size":112024,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-05T20:06:38.230Z","etag":null,"topics":["android","android-location","android-location-navigator","flutter","flutter-apps","flutter-examples","flutter-plugin","location-services","locationprovider"],"latest_commit_sha":null,"homepage":"https://itzmeanjan.github.io/locate/","language":"Kotlin","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/itzmeanjan.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-03-06T18:34:21.000Z","updated_at":"2022-09-26T05:46:31.000Z","dependencies_parsed_at":"2022-09-08T07:42:02.657Z","dependency_job_id":null,"html_url":"https://github.com/itzmeanjan/locate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Flocate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Flocate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Flocate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Flocate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itzmeanjan","download_url":"https://codeload.github.com/itzmeanjan/locate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240093142,"owners_count":19746774,"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":["android","android-location","android-location-navigator","flutter","flutter-apps","flutter-examples","flutter-plugin","location-services","locationprovider"],"created_at":"2024-09-30T17:06:36.353Z","updated_at":"2025-02-23T15:31:52.291Z","avatar_url":"https://github.com/itzmeanjan.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"![logotype-horizontal](./logo/logotype-horizontal.png)\n\n# locate\n\nA Flutter plugin to fetch GPS/ Network based Location Data Feed on Android.\n\n**locate v1.2.0 is readily availble for [use](https://pub.dev/packages/locate).** \n\n# intro\n\n`locate` can be used on Android for fetching Location Data Feed.\n\nTwo location service providers are available\n\n- Google Mobile Services i.e. GMS based _FusedLocationProvider_ **( this is recommended )**\n- Standard Android _LocationManager_ **( in this case you get freedom to choose which provider to use )**\n  - Network provider\n  - GPS provider\n\nIt has **androidX** support, along with latest version of all dependencies.\n\n# installation\n\n- Add `locate` as dependency in in your flutter project's pubspec.yaml\n\n```yaml\ndependencies:\n  locate: ^1.2.0\n```\n\n- Fetch flutter packages from pub.dev\n\n```bash\n$ flutter pub get\n```\n\n- Import `locate` in your dart code \u0026 start getting location data feed\n\n```dart\nimport 'package:locate/locate.dart';\n```\n\n# usage\n\n## permission\n\n- First thing first, add permission declaration in your project's `AndroidManifest.xml`.\n\n  - If you're planning to use Google Mobile Services based _FusedLocationProvider_, request for *ACCESS_FINE_LOCATION*, which automagically selects location data source for you.\n  - Otherwise you may only request for \n    - *ACCESS_FINE_LOCATION* _( GPS based location data )_\n    - *ACCESS_COARSE_LOCATION* _( Network based location data )_\n\n```xml\n\u003cuses-permission android:name=\"android.permission.ACCESS_{FINE, COARSE}_LOCATION\"/\u003e\n```\n\n## API\n\n- Get an intance of *Locate*.\n\n```dart\nvar _locate = Locate();\n```\n\n- Let's first request Location Access Permission from user.\n\n```dart\n_locate.requestLocationPermission().then((bool result) {\n                  if (result)\n                    // we're good to go\n                  else\n                    // let user know it's required\n                  });\n```\n\n- Time to enable Location.\n\n```dart\n_locate.enableLocation().then((bool result) {\n                      if (result) {\n                        // update UI \u0026 request *locate* for location Data\n                        setState(() =\u003e _areWeGettingLocationUpdate = true);\n                        // Location data will be fetched and delivered as Stream\u003cMyLocation\u003e\n                      else\n                        // user didn't enable location\n                      }\n                    });\n```\n\n- Now we start getting Location Data Feed.\n\n```dart\n_locate.getLocationDataFeed()\n                          ..listen(\n                            // we listen for location data, which is received as stream\n                            (MyLocation data) =\u003e\n                                setState(() =\u003e _locationData.add(data)), // as soon as data received, will update UI/ perform some other task using location data.\n                            cancelOnError: true,\n                            onError: (e) =\u003e print(e),\n                          );\n```\n\n- Aah I just forgot to mention one thing, *how to stop listening location update ?*\n\n```dart\n_locate.stopLocationDataFeed().then((bool result) {\n  // do some UI updation kind of work/ or something else\n});\n```\n\n## what's in **MyLocation** class ?\n\n- *MyLocation* class can be thought of as a Location Data container \u0026 manipulator.\n\n```dart\n/// constructor of MyLocation\nMyLocation(\n      this.longitude,\n      this.latitude,\n      this.time, // in DateTime\n      this.altitude, // in meters\n      this.bearing, // in degree\n      this.speed, // in meters/s\n      this.accuracy, // in meters\n      this.verticalAccuracy, // in meters\n      this.bearingAccuracy, // in meters\n      this.speedAccuracy, // in meters/s\n      this.provider, // as String,either gps/ network/ fused\n      this.satelliteCount);\n```\n\n- I've added some companion methods which can be used from *MyLocation*, such as \n\n```dart\n// will fetch you name of direction of movement from bearing value\nbearingToDirectionName();\n\n// m/s to km/h converion for speedaccuracy\ngetSpeedAccuracyInKiloMetersPerHour();\n\n/// same as above, but works on speed\ngetSpeedInKiloMetersPerHour();\n\n/// displays time in pretty format\ngetParsedTimeString();\n```\n\n## example\n\nHere's an [example](./example) application using all these API(s).\n\n# notes\n\nYou can also set some optional named parameters while invoking methods from *Locate* class.\n\nWhile requesting permission, you can set *provider*\n  - *LocationProvider.Network*, if you want to use Network based Location\n  - *LocationProvider.GPS*, if you want to use GPS based Location **[ default ]**\n\nBefore requesting Location Data Feed, you can also set via which location manager to fetch data and location data provider name.\n\n  - For `LocationServiceProvider.GMSBasedLocation`, make sure you've declared \u0026 requested for permission of accessing FINE Location.\n  - Otherwise for `LocationServiceProvider.LocationManagerBasedLocation` as `locationServiceProvider`, you may use any of them, depending upon your declared \u0026 requested permissions. \n    - `LocationProvider.GPS`\n    - `LocationProvider.Network`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzmeanjan%2Flocate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitzmeanjan%2Flocate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzmeanjan%2Flocate/lists"}