Dart client for the Traccar geolocation server. Get real time devices positions updates from a Traccar server.
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
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}");
});
trac.query.devices().then((List<Device> devices) {
print("$devices");
});
final List<Device> pos = await trac.query.positions(
deviceId: "1", since: Duration(hours: 3));
Device: representation of a device
GeoPoint: geographical datapoints: data structure
To run the example put your server address and user token in conf.dart