wialon 2.0.1 copy "wialon: ^2.0.1" to clipboard
wialon: ^2.0.1 copied to clipboard

WialonSDK for Dart Language

example/main.dart

import 'package:wialon/wialon.dart';

void main(List<String> arguments) async {
  await login();
  await getUnits();
  await reverseGeocoding();
}

Future<void> login() async {
  WialonSdk sdk = WialonSdk();
  Map<String, dynamic> loginResult = await sdk.login(token: '<your token here>');
  print(loginResult);

  /// !Important note:
  /// If you don't want to create algorithms to store the Wialon session, we suggest to perform the logout method at the end of the program.
  await sdk.logout();
}

Future<void> getUnits() async {
  WialonSdk sdk = WialonSdk();
  await sdk.login(token: '<your token here>');

  Map<String, dynamic> result = await sdk.call(
    method: 'core/search_items',
    parameters: {
      'spec': {
        'itemsType': 'avl_unit',
        'propName': 'sys_name',
        'propValueMask': '*',
        'sortType': 'sys_name',
        'or_logic': true,
      },
      'force': 1,
      'flags': 1,
      'from': 0,
      'to': 0
    },
  );

  /// Your units should will come in [result['items']]
  print(result['items']);

  await sdk.logout();
}

Future<void> reverseGeocoding() async {
  WialonSdk sdk = WialonSdk();
  await sdk.login(token: '<your token here>');

  String result = await sdk.reverseGeocoding(latitude: 0, longitude: 0);

  /// If your reverse server configured in Wialon can handle your coordinates
  /// (For this example, [latitude] and [longitude] are 0), you should get a result.
  /// Otherwise, you should get an empty string.
  ///
  /// If you run this script (Placing your token, of course), the response will be an empty string.
  print(result);

  await sdk.logout();
}