Skip to content
Developer documentation

Dart

Dart 3.4+

Dart

Dart 3.4+

A generated Dart client exposing every public operation with typed requests and responses. Use it for server-side Dart, CLI tooling and Flutter apps that want the REST API without the map widget.

Install

dart pub add bardiyamap_sdk

What it supports

  • Every public Maps operation
  • Every public Tracking operation, including streams
  • Typed request and response models generated from the contract
  • Explicit error type carrying status, code and request id

Initialise the client

dart
import 'package:bardiyamap_sdk/bardiyamap_sdk.dart';

final client = BardiyaClient(BardiyaConfig(
  credentials: BardiyaCredentials(
    mapsApiKey: Platform.environment['BARDIYA_MAPS_API_KEY'],
    trackingApiKey: Platform.environment['BARDIYA_TRACKING_API_KEY'],
  ),
));

Typical operations

Places and directions

dart
final places = await client.places.searchPlaces(
  'coffee',
  latitude: 30.0444,
  longitude: 31.2357,
  limit: 3,
);

final directions = await client.directions.directions(
  DirectionsPublicRequest(
    origin: PublicCoordinate(latitude: 30.0444, longitude: 31.2357),
    destination: PublicCoordinate(latitude: 30.0626, longitude: 31.2497),
  ),
  xStrictRoadNetwork: 'true',
);

Geocoding in Arabic

dart
final forward = await client.geocoding.forwardGeocode(
  '٥ شارع النصر، مدينة نصر، القاهرة',
  latitude: 30.0397,
  longitude: 31.2035,
  limit: 10,
  language: 'ar',
);

final reverse = await client.geocoding.reverseGeocode(
  30.0397,
  31.2035,
  nearbyLimit: 5,
  language: 'ar',
);

Error handling

dart
try {
  await client.places.searchPlaces('coffee');
} on BardiyaApiException catch (failure) {
  print(failure.statusCode); // 422
  print(failure.code);       // "invalid_coordinates"
  print(failure.requestId);
}

Things that catch people out

  • Credentials are nullable: configure only the families you use. Calling a maps method without a maps key throws before the request is sent.
  • The client is per-isolate. Do not share one instance across isolates.