تخطَّ إلى المحتوى
توثيق المطورين

فلاتر

Flutter 3.29+ (depends on bardiyamap_sdk)

فلاتر

Flutter 3.29+ (depends on bardiyamap_sdk)

The widget layer: a MapLibre-backed BardiyaMap widget, a map controller, route and marker overlays, and a realtime controller for a tracking session. Data access is delegated to bardiyamap_sdk.

Install

flutter pub
flutter pub add bardiyamap_flutter

What it supports

  • BardiyaMap widget with styles, camera, routes, markers and current location
  • BardiyaMapController for camera and route fitting
  • BardiyaRealtimeController for one session's stream
  • Android and iOS

Initialise the client

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

BardiyaMap(
  style: proxiedStyleUrl, // a style with your proxied tile URLs, never a raw key
  initialCameraPosition: const CameraPosition(
    target: LatLng(30.0444, 31.2357),
    zoom: 12,
  ),
  route: BardiyaRoute.fromDirectionsResponse(directionsResponse),
  markers: const [
    BardiyaMarker(id: 'vehicle-1', latitude: 30.05, longitude: 31.24, label: 'Rider 1'),
  ],
);

Typical operations

Realtime controller

dart
final realtime = BardiyaRealtimeController.forSession(
  client: client,             // a bardiyamap_sdk client
  sessionId: sessionId,
  credential: sessionCredential,
);
await realtime.start();

@override
void dispose() {
  realtime.dispose();         // stop the stream before the widget goes away
  super.dispose();
}

Fit a route to the viewport

dart
BardiyaMap(
  style: style,
  initialCameraPosition: const CameraPosition(target: LatLng(30.0444, 31.2357), zoom: 11),
  route: route,
  onBardiyaMapCreated: (controller) => controller.fitRoute(route),
);

Things that catch people out

  • The widget renders whatever style you give it. To keep your key off the device, serve the style from your backend with rewritten source URLs.
  • Always dispose the realtime controller: an undisposed controller keeps a network stream and a timer alive.
  • Map rendering, REST access and realtime are three separate capabilities. Enabling one does not enable the others.