Filip
Filip

Reputation: 2411

How to get latitude and longitude in background service?

As in the question. How to track location in background service in flutter?

Upvotes: 1

Views: 858

Answers (3)

kiran kumar
kiran kumar

Reputation: 1422

  1. Add geolocator: ^4.0.3
  2. import 'package:geolocator/geolocator.dart';
  3. Add permissions for android & ios
  4. Use the below code

    void getLocation() async {
    Position position = await Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    print(position);
    }
    

Upvotes: 1

Sunny
Sunny

Reputation: 3265

Here is the offical Link with plugin and whole code.

Upvotes: 0

Sergio Bernal
Sergio Bernal

Reputation: 2327

Just use the geolocator plugin, you only need one line of code!

Upvotes: 1

Related Questions