Get started

Troubleshooting

The failures developers meet first with the Dart SDK, each with its fix.

SecretCredential is not defined in my app

SecretCredential and constructWebhookEvent exist on the Dart VM only. A Flutter build leaves them out, so a secret key cannot ship inside an app. Mint session tokens and verify webhooks on your server, and give the app a publishable key with a SessionTokenEngine.

The client throws ConfigurationException as it is built

The key is empty or misprefixed. String.fromEnvironment answers '' when the build was not given the value:

flutter run --dart-define-from-file=.env

Check that .env holds MOUNTAYA_PUBLISHABLE_KEY=pk_…, and rebuild: the value is compiled in.

Search or a Data API call answers 401

The Data API answers a publishable key only beside a live session token. A token held as a value expires in minutes: give the client a SessionTokenEngine, which mints again before it does:

import 'package:mountaya_client/mountaya_client.dart';
import 'package:mountaya_client/rest_schema.dart' as rest_schema;

const publishableKey = String.fromEnvironment('MOUNTAYA_PUBLISHABLE_KEY');

// Your app's call to your session route, as Authentication in the SDK shows.
Future<rest_schema.Session> mintSession() =>
    throw UnimplementedError('Ask your server for a session.');

final mountaya = Mountaya(
  credential: .publishable(
    key: publishableKey,
    sessionToken: .source(SessionTokenEngine(mint: mintSession)),
  ),
);
await mountaya.close();

The map is blank in a release build on Android

Flutter's template grants the network to debug builds only. Declare it in android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

The build refuses the iOS or Android version

The map plugin needs iOS 15.5 and Android API level 24, the navigation plugin iOS 14.0 and API level 24. Raise the Runner target's Minimum Deployments in Xcode, platform :ios in ios/Podfile, and minSdk in android/app/build.gradle.kts, as Install and set up shows.

MapEngine refuses my client

A map takes a publishable key alone, with a session token as a value or a SessionTokenEngine, or a share token. It refuses a secret key, and a session token read by a function, with ConfigurationException. Build the map's client with .source(sessions) or .value(token).

The map stays empty

map.state.isAccessRequired is true and events() tells a MapEventAccessRefused. The key lacks a scope: tiles draws the map, publishing reads an itinerary. Add the scope under Organization → API keys in the Mountaya app.

A panel opens under the controls

A panel opens in the nearest Overlay. A Navigator provides one; under a bare WidgetsApp with a builder, wrap the screen in one:

import 'package:flutter/widgets.dart';

// A screen of yours that holds MapView and MapControls.
Widget withOverlay(Widget screen) => WidgetsApp(
  color: const Color(0xff1c7ed6),
  builder: (context, _) => Overlay(
    initialEntries: [OverlayEntry(builder: (context) => screen)],
  ),
);

A write answers 401

A write to an itinerary, a collection or a zone acts as a member. Mint its token with user_id and surface: rest_schema.SessionSurface.studioEmbedded, beside a key carrying the studio-embedded scope, as Act as a member shows.

A call answers 402

A BillingException means your agreement does not cover the call, or a payment is missing. Its message says which: change the product with Mountaya, or add a payment method in your billing settings. Code cannot fix it.

A webhook delivery never verifies

constructWebhookEvent throws WebhookSignatureException, and its reason says why. A signature reason means the body changed or the secret is wrong: pass the body exactly as it arrived, and the secret of the endpoint the delivery was sent to. A timestamp reason means your server's clock is off.

Navigation says nothing

The engine speaks only through the voice you hand it, and only the instructions your words function answers. Hand DeviceNavigationEngine(voice:) a SpeechNavigationVoice, give it an onError, and answer a sentence for each key you use, as Speak the prompts shows.

No cut-off times appear

The profile, the waypoint table and the card write a cut-off only through your formatCutoffAt, in the device's time zone. Read it with deviceTimeZone() and write with formatDateTime, as Show services and cut-offs shows.

Navigation reads no position

DeviceLocationSource reads only while your app holds location access at full accuracy, and never asks for it. Ask in your own flow, declare the purpose string and permissions (use the device's location), then call recheckPermission().

Next steps

Last updated