Yatmo Flutter SDK

A Dart package: a YatmoMapView widget built on maplibre_gl, and a typed client for the REST API. One codebase for iOS and Android.

Requirements

Install

dependencies:
  yatmo_sdk: ^1.0.0           # pub.dev, pulls maplibre_gl
  package_info_plus: ^8.0.0   # optional, to read the app id at runtime

Package page: pub.dev/packages/yatmo_sdk; source and releases on github.com/yatmo/yatmo-sdk-flutter.

Configure

import 'package:package_info_plus/package_info_plus.dart';
import 'package:yatmo_sdk/yatmo_sdk.dart';

late final YatmoClient yatmo;

Future<void> initYatmo() async {
  final info = await PackageInfo.fromPlatform();
  yatmo = YatmoClient(YatmoConfiguration(
    licenseKey: 'YOUR_FRONTEND_KEY',
    country: Country.be,
    language: Language.fr,
    appId: info.packageName, // bundle id on iOS, applicationId on Android
  ));
}

The map widget

import 'package:yatmo_sdk/yatmo_sdk.dart';

class ListingMap extends StatelessWidget {
  const ListingMap({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 320,
      child: YatmoMapView(
        client: yatmo,
        property: const LatLng(50.8520525, 4.3442926),
        zoom: 15,
        mapStyle: YatmoMapStyle.liberty,
        isochrones: TravelMode.walking,
        onPoiSelected: (poi) => debugPrint('${poi.name} (${poi.type})'),
      ),
    );
  }
}

The widget wraps a MapLibreMap with the Yatmo style, the property pin, POI symbols that follow the camera (debounced, from zoom 13) and isochrone fills. The MapLibreMapController is handed to you through onMapCreated if you need to add your own layers.

Parameters

Name In Type Description
client required YatmoClient Configured client.
property required LatLng Pin position and initial centre.
zoom double Initial zoom. Default: 15.
mapStyle YatmoMapStyle liberty, basic, bright, threeD, positron, dark, libertyStonehedge. Default: liberty.
poiTypeIds List<int>? Category ids from client.simplifiedCategories(). Default: all.
poiIconSize int 24 or 32. Default: 24.
isochrones TravelMode? Draws the 5 / 10 / 20 minute areas when set.
fitIsochrones / isochronePadding bool / double Like the web plugin: once the isochrones are drawn the camera fits the largest area; setting isochrones back to null restores the previous camera. Default: true / 40.
minZoomForPois double No POI request below this zoom. Default: 13.
onPoiSelected void Function(YatmoPoi) Symbol tapped.
onError void Function(Object) Network or licence errors.
onMapCreated void Function(MapLibreMapController) Access to the raw controller.

Data: YatmoClient

final summary = await yatmo.summary(latitude: 50.8520525, longitude: 4.3442926);
for (final category in summary.categories) {
  debugPrint(category.label);
  for (final sub in category.subCategories) {
    debugPrint('  ${sub.label}: ${sub.places.length}');
  }
}

final text = await yatmo.summaryText(latitude: 50.8520525, longitude: 4.3442926);
final scores = await yatmo.scores(latitude: 50.8520525, longitude: 4.3442926);
final enrichment = await yatmo.enrichment(latitude: 50.8520525, longitude: 4.3442926);
final places = await yatmo.geocode(query: 'Rue Neuve', latitude: 50.85, longitude: 4.35);
final pois = await yatmo.points(southWest: const LatLng(50.848, 4.338), northEast: const LatLng(50.856, 4.350));
final isochrones = await yatmo.isochrones(mode: TravelMode.walking, latitude: 50.8520525, longitude: 4.3442926);
final groups = await yatmo.simplifiedCategories();

Errors are thrown as YatmoException with statusCode and message. Shapes: Summary, Enrichment, Points, Isochrone, Geolocation.

WebView fallback

The package does not depend on webview_flutter. To show the full web plugin, build the URL with the helper and load it in your WebView of choice:

import 'package:webview_flutter/webview_flutter.dart';

final url = yatmo.pluginUrl(latitude: 50.8520525, longitude: 4.3442926, mode: 'overlay', zoom: 15);
final controller = WebViewController()
  ..setJavaScriptMode(JavaScriptMode.unrestricted)
  ..loadRequest(Uri.parse(url));
// then: WebViewWidget(controller: controller)

Related: React Native SDK · WebView, Capacitor, Ionic · Overview.