traccar_client 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 51

Traccar client #

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;

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}");
   });

Run queries #

Query for a list of devices:

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

Data structure #

The position stream outputs Device objects with updated positions:

   class Device {
     final int id;
     String uniqueId;
     int groupId;
     String name;
     double batteryLevel;
     int keepAlive;
     bool isDisabled;
     bool isActive;
     DevicePosition position;
   }

   class DevicePosition {
     final int id;
     final LatLng point;
     final double accuracy;
     final double altitude;
     final double speed;
     final double distance;
     final double totalDistance;
     final String address;
     final DateTime date;
   }

Example #

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

Changelog #

0.1.0 #

Initial

example/README.md

Example #

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

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

void main() async {
  final trac =
      Traccar(serverUrl: serverUrl, userToken: userToken, verbose: true);
  unawaited(trac.init());
  await trac.onReady;

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

  /// devices
  await trac.query.devices().then((List<Device> devices) {
    print("DEVICES LIST:");
    print("$devices");
  });
}

Use this package as a library

1. Depend on it

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


dependencies:
  traccar_client: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:traccar_client/traccar_client.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
5
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
51
Learn more about scoring.

We analyzed this package on Oct 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:traccar_client/traccar_client.dart with components: io.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (dio).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
dio ^2.1.16 2.2.2 3.0.3
geopoint ^0.5.0 0.5.0
latlong ^0.6.1 0.6.1
meta ^1.1.6 1.1.7
pedantic ^1.6.0 1.8.0+1
web_socket_channel ^1.0.15 1.1.0
Transitive dependencies
ansicolor 1.0.2
async 2.4.0
charcode 1.1.2
collection 1.14.12
console_log_handler 1.1.6
convert 2.1.1
cookie_jar 1.0.1
crypto 2.1.3
intl 0.16.0
logging 0.11.3+2
path 1.6.4
slugify2 0.2.1
stream_channel 2.0.0
typed_data 1.1.6
validate 1.7.0