Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.
/ traccar_client Public archive

Dart client for the Traccar geolocation server

License

Notifications You must be signed in to change notification settings

synw/traccar_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Traccar client

pub package

Dart client for the Traccar geolocation server. Get real time devices positions updates from a Traccar server.

Usage

Initialize

import 'package:pedantic/pedantic.dart';
import 'package:traccar_client/traccar_client.dart';
import 'conf.dart';

/// [serverUrl] and [userToken] are taken from conf
final trac = Traccar(serverUrl: serverUrl, userToken: userToken);
unawaited(trac.init());
await trac.onReady;

The token is a user token that you can generate from the Traccar web interface

Listen for positions updates

final positions = await trac.positions();
print("Listening for position updates");
positions.listen((device) {
   print("POSITION UPDATE: $device");
   print("${device.id}: ${device.position.geoPoint.latitude} / " +
      "${device.position.geoPoint.longitude}");
});

Get a list of devices

trac.query.devices().then((List<Device> devices) {
   print("$devices");
});

Get positions history for a device

   final List<Device> pos = await trac.query.positions(
      deviceId: "1", since: Duration(hours: 3));

Data structure

Device: representation of a device

GeoPoint: geographical datapoints: data structure

Example

To run the example put your server address and user token in conf.dart

About

Dart client for the Traccar geolocation server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages