All Projects → Almoullim → Background_location

Almoullim / Background_location

Licence: other
Flutter background location plugin for Android and iOS

Programming Languages

swift
15916 projects
kotlin
9241 projects
dart
5743 projects

Projects that are alternatives of or similar to Background location

Amap location fluttify
高德地图 定位组件 Flutter插件
Stars: ✭ 97 (-23.62%)
Mutual labels:  flutter-plugin
Super enum
Create super-powered dart enums similar to sealed classes in Kotlin
Stars: ✭ 114 (-10.24%)
Mutual labels:  flutter-plugin
Flutteryoutube
Flutter Plugin to play youtube Videos
Stars: ✭ 120 (-5.51%)
Mutual labels:  flutter-plugin
Launch review
A Flutter plugin to assist in leaving user reviews/ratings in the Google Play Store. Supports both Android and iOS.
Stars: ✭ 98 (-22.83%)
Mutual labels:  flutter-plugin
Flutter local notifications
A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
Stars: ✭ 1,724 (+1257.48%)
Mutual labels:  flutter-plugin
Flutter Adaptivecards
AdaptiveCards for Flutter 🐦
Stars: ✭ 117 (-7.87%)
Mutual labels:  flutter-plugin
Flutter weather bg
A rich and cool weather dynamic background plug-in
Stars: ✭ 89 (-29.92%)
Mutual labels:  flutter-plugin
Nautilus
阿里百川电商Flutter插件。
Stars: ✭ 123 (-3.15%)
Mutual labels:  flutter-plugin
Drawer Behavior Flutter
Drawer behavior is a library that provide an extra behavior on drawer, such as, move view or scaling view's height while drawer on slide.
Stars: ✭ 110 (-13.39%)
Mutual labels:  flutter-plugin
Esys Flutter Share
A Flutter plugin for sharing files & text with other applications.
Stars: ✭ 119 (-6.3%)
Mutual labels:  flutter-plugin
Painter
A simple flutter widget to paint with your fingers
Stars: ✭ 99 (-22.05%)
Mutual labels:  flutter-plugin
Nav router
flutter The lightest, easiest and most convenient route management!
Stars: ✭ 101 (-20.47%)
Mutual labels:  flutter-plugin
Youtube player
A flutter plugin to play Youtube Videos without API Key in range of Quality(144p, 240p,360p,480p,720p and 1080p).
Stars: ✭ 118 (-7.09%)
Mutual labels:  flutter-plugin
Flutter Apps Collection
This is a repository of a collection of apps made in flutter
Stars: ✭ 98 (-22.83%)
Mutual labels:  flutter-plugin
Facebook audience network
Flutter Facebook Audience Network
Stars: ✭ 122 (-3.94%)
Mutual labels:  flutter-plugin
Octo image
A multifunctional Flutter image widget
Stars: ✭ 97 (-23.62%)
Mutual labels:  flutter-plugin
Edge detection
This is a flutter plugin to detect edges in a live camera, take the picture of detected edges object, crop it, and save.
Stars: ✭ 116 (-8.66%)
Mutual labels:  flutter-plugin
Plugins
go-flutter implementations for popular Flutter plugins
Stars: ✭ 125 (-1.57%)
Mutual labels:  flutter-plugin
Flutter Concentric Transition
A Flutter plugin to create views using concentric transition effect.
Stars: ✭ 122 (-3.94%)
Mutual labels:  flutter-plugin
Flutter contacts
A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit
Stars: ✭ 119 (-6.3%)
Mutual labels:  flutter-plugin

Background Location

A Flutter plugin to get location updates in the background for both Android and iOS (Requires iOS 10.0+). Uses CoreLocation for iOS and FusedLocationProvider for Android

Getting Started

1: Add this to your package's pubspec.yaml file:

dependencies:
  background_location: ^0.4.1

2: Install packages from the command line:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

How to use

Import the package where you wanna use it.

import 'package:background_location/background_location.dart';

Request permissions from the user.

BackgroundLocation.getPermissions(
  onGranted: () {
    // Start location service here or do something else
  },
  onDenied: () {
    // Show a message asking the user to reconsider or do something else
  },
);

You can check if you have permissions at anytime with checkPermissions()

BackgroundLocation.checkPermissions().then((status) {
  // Check status here
});

Set the notification title, message and icon (Android only). Use await or .then if you wanna start the location service immediatly after becuase its an asynchronous method

BackgroundLocation.setAndroidNotification(
	title: "Notification title",
        message: "Notification message",
        icon: "@mipmap/ic_launcher",
);

Set the interval between localisations in milliseconds (Android only). Use await or .then if you wanna start the location service immediatly after becuase its an asynchronous method

BackgroundLocation.setAndroidConfiguration(1000);

Start the location service. This will also ask the user for permission if not asked previously by another package.

BackgroundLocation.startLocationService();

Start location service by specifying distanceFilter. Defaults to 0 if not specified

BackgroundLocation.startLocationService(distanceFilter : 10);

getLocationUpdates will trigger everytime the location updates on the device. Provide a callback function to getLocationUpdates to handle location update.

BackgroundLocation.getLocationUpdates((location) {
  print(location);
});

location is a Class exposing the following properties.

double latitude;
double longitude;
double altitude;
double bearing;
double accuracy;
double speed;
double time;
bool isMock;

To stop listening to location changes you can execute.

BackgroundLocation.stopLocationService();

Make sure to delcare all required permissions for both your android and ios app

info.plist

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location.</string>
<key>UIBackgroundModes</key>
<array>
	<string>fetch</string>
	<string>location</string>
</array>

AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/> 

Example

Complete working application Example

Todo

  • [x] Add support for manually asking for permission.
  • [x] Add support for checking the permission status.
  • [x] Add support for chosing the rate at the which the location is fetched based on time and distance.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].