Dart and Flutter SDK
Outdoor maps as Flutter widgets
mountaya_client calls the Map Studio API, the Data API and the Tile API in pure Dart, from a Flutter app or a server. On Android and iOS, mountaya_elements_flutter draws the map, the elevation profile and the itinerary tables.
Works with the tools you already use
Challenges we solve
Call every Mountaya API from Dart, and draw the answer in Flutter.
Pure Dart, on a server too
The client, the admin unit and the geo layer are pure Dart. A server or a command-line tool adds them and resolves no Flutter.
No secret key in a Flutter build
The secret-key credential is declared on the Dart VM alone. A Flutter build has no symbol to hold one, so the mistake does not compile.
No map or speech plugin to add
The plugins' native sides draw the map, read the location and speak. Your app adds no maplibre_gl unless it drives MapLibre's controller itself.
Packages
What you install for Dart and Flutter
Packages on pub.dev, all at one version. The client is pure Dart, and the elements are a Flutter plugin for Android and iOS. mountaya_geo, mountaya_navigation_flutter and mountaya_admin publish beside them.
mountaya_client
dart pub add mountaya_client
mountaya_elements_flutter
flutter pub add mountaya_client mountaya_geo mountaya_elements_flutter
Integration
From pub add to a map in Flutter
Each snippet carries its own imports. The server step runs on the Dart VM, and the rest in your Flutter app.
Install
An app adds the client, the geo layer and the map plugin. It declares no maplibre_gl: the plugin depends on it.
flutter pub add mountaya_client mountaya_geo mountaya_elements_flutterAuthenticate
The Data API takes a session token beside the publishable key. Your server mints it on the Dart VM, through the admin unit.
import 'package:mountaya_admin/admin_schema.dart' as admin_schema;
import 'package:mountaya_admin/mountaya_admin.dart';
import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_client/rest_schema.dart' as rest_schema;
// On your backend: the secret key, which never leaves the server.
final server = Mountaya(credential: SecretCredential('sk_your_secret_key'));
// What your app's `mint` asks your backend for: a session for the user signed in to it.
Future<rest_schema.Session> mintFor(String userId) async {
final minted = await server.admin.sessions.postSession(
body: admin_schema.SessionCreateParams(
publishable_key: 'pk_your_publishable_key',
user_id: userId,
),
);
return minted.data;
}Call
SessionTokenEngine mints through your function and refreshes before expiry. Each operation returns a Future and is named by its operation id.
import 'dart:convert';
import 'dart:io';
import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_client/rest_schema.dart' as rest_schema;
// In an app: your backend mints the session token with its secret key.
Future<rest_schema.Session> fetchSession() async {
final http = HttpClient();
try {
final request = await http.getUrl(Uri.parse('https://example.com/api/mountaya-session'));
final response = await request.close();
return rest_schema.Session.fromJson(jsonDecode(await response.transform(utf8.decoder).join()));
} finally {
http.close();
}
}
Future<void> main() async {
final sessions = SessionTokenEngine(mint: fetchSession);
final client = Mountaya(
credential: .publishable(key: 'pk_your_publishable_key', sessionToken: .source(sessions)),
);
final itinerary = await client.studio.itineraries.getItinerary(
itinerary_id: '0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21',
);
print(itinerary.data.name);
await client.close();
}Render
Your State owns the MapEngine and closes it in dispose. MapView draws it, and every tile request carries your client's credential.
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_elements_flutter/mountaya_elements_flutter.dart';
class TrailMap extends StatefulWidget {
const TrailMap({super.key, required this.mountaya});
final Mountaya mountaya;
@override
State<TrailMap> createState() => _TrailMapState();
}
class _TrailMapState extends State<TrailMap> {
late final MapEngine map = MapEngine(widget.mountaya);
@override
void initState() {
super.initState();
unawaited(map.setTerrain());
}
@override
void dispose() {
map.close();
super.dispose();
}
@override
Widget build(BuildContext context) => MapView(engine: map);
}What will you build with the SDKs & Elements?
Tell us what your product needs to draw. We show you the SDKs & Elements that draw it.
Frequently asked questions
An app that shows a map adds mountaya_client, mountaya_geo and mountaya_elements_flutter. An app that navigates adds mountaya_navigation_flutter, which reads the device's location and speaks each maneuver.
The Flutter plugins need Flutter 3.44 and run on Android from API level 24. On iOS, the map runs from 15.5 and navigation from 14. The pure packages need Dart 3.10. No web or desktop build is published.
Yes. mountaya_client, mountaya_admin and mountaya_geo resolve no Flutter, no MapLibre and no native code. A server mints session tokens with its secret key and verifies webhooks with constructWebhookEvent.
Yes, in Dart's own idiom. Each method carries the schema's operation id, and SessionTokenEngine and constructWebhookEvent keep their names in the TypeScript, Swift and Kotlin SDKs. The layers match too: the client, the geo layer and the map. Embedded Studio stays React only.