20 skills · 65 min
Skills
Skill 4 of 20
Official integration patterns for the Mapbox Maps Flutter SDK.
2 minutes · 519 words · 24 sections
Install
npx skills add mapbox/mapbox-agent-skills --skill mapbox-flutter-patternsnpx skills add mapbox/mapbox-agent-skills/plugin marketplace add mapbox/mapbox-agent-skillsThe first command installs just this skill, by the name in its SKILL.md; the second installs the whole repository.
Official patterns for integrating the Mapbox Maps SDK for Flutter (mapbox_maps_flutter) on iOS and Android with Dart.
Use this skill when:
MapWidget with camera / style optionsOfficial Resources:
Web and desktop are not supported — the Flutter SDK targets iOS and Android only.
# pubspec.yaml
dependencies:
mapbox_maps_flutter: ^2.0.0flutter pub getThis is the single most common cause of iOS build failures after adding Mapbox. The Flutter SDK requires iOS 14.0 and will not compile on the Flutter default.
Open ios/Runner.xcworkspace in Xcode.
Select the Runner target → General → set Minimum Deployments → iOS to 14.0.
If ios/Podfile exists, update the platform line too:
# ios/Podfile
platform :ios, '14.0'You do not need to worry about CocoaPods vs Swift Package Manager — mapbox_maps_flutter supports both and Flutter picks whichever your app is configured for.
Add the purpose string to ios/Runner/Info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Show your location on the map</string>Add to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />The recommended pattern is to pass the token via --dart-define at build/run time and set it on MapboxOptions before creating any MapWidget.
flutter run --dart-define=ACCESS_TOKEN=pk.your_token_here// main.dart
import 'package:flutter/material.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
const accessToken = String.fromEnvironment('ACCESS_TOKEN');
void main() {
MapboxOptions.setAccessToken(accessToken);
runApp(const MaterialApp(home: MapScreen()));
}Never hard-code tokens in source. For CI, pass --dart-define=ACCESS_TOKEN=$MAPBOX_ACCESS_TOKEN.
import 'package:flutter/material.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
class MapScreen extends StatelessWidget {
const MapScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: MapWidget(
MapboxMap controllerclass MapScreen extends StatefulWidget {
const MapScreen({super.key});
@override
State<MapScreen> createState() => _MapScreenState();
}
class _MapScreenState extends State<MapScreen> {
MapboxMap
Use mapboxMap.annotations to create managers for point, circle, polyline, and polygon annotations. Managers are long-lived — create them once and reuse for updates.
import 'package:flutter/services.dart' show rootBundle;
PointAnnotationManager? pointAnnotationManager;
Future<void> _addMarkers(MapboxMap mapboxMap) async {
pointAnnotationManager = await mapboxMap.annotations.createPointAnnotationManager();
final bytes = await
Remember to register the asset in pubspec.yaml:
flutter:
assets:
- assets/marker.pngUse manager.tapEvents — this is the current API. addOnPointAnnotationClickListener is deprecated.
tapEvents returns a Cancelable that you store and invoke .cancel() on when the listener is no longer needed:
final Cancelable tapSubscription = pointAnnotationManager!.tapEvents(
onTap: (annotation) {
debugPrint('Tapped annotation ${annotation.id}');
},
);
@override
void dispose() {
tapSubscription.cancel();
super.dispose
The same pattern — returning a Cancelable — exists on every manager’s longPressEvents and dragEvents, and across the other annotation types (CircleAnnotationManager.tapEvents, etc.).
import 'dart:convert';
import 'package:flutter/services.dart' show rootBundle;
Future<void> _loadGeoJson(MapboxMap mapboxMap) async {
final raw = await rootBundle.loadString('assets/coffee_shops.geojson');
final
For thousands of features use a style layer (GeoJsonSource + SymbolLayer) instead of annotations.
Permissions must already be granted (use permission_handler or similar) before enabling the puck.
await mapboxMap.location.updateSettings(LocationComponentSettings(
enabled: true,
puckBearingEnabled: true,
locationPuck: LocationPuck(
locationPuck2D: DefaultLocationPuck2D(),
),
));// Instant jump
await mapboxMap.setCamera(CameraOptions(
center: Point(coordinates: Position(-80.1263, 25.7845)),
zoom: 14,
));
// Animated fly-to
await mapboxMap.flyTo(
CameraOptions(
center
The Flutter default iOS deployment target is lower than Mapbox’s minimum (iOS 14). Set Minimum Deployments → iOS to 14.0 on the Runner target in Xcode. If the project has an ios/Podfile, also set platform :ios, '14.0' there and re-run pod install.
setAccessToken not calledIf you forget to call MapboxOptions.setAccessToken before creating a MapWidget, the map will load with a blank grid. Always call it in main() before runApp.
Make sure you’re using manager.tapEvents(onTap: ...) — addOnPointAnnotationClickListener is deprecated. Also confirm the MapboxMap controller is captured via onMapCreated before you create the annotation manager.
iOS/Android will not re-read manifests or Info.plist on hot reload. Fully restart the app after editing permissions.
references/annotations.md — Circle, Polyline, Polygon patterns and GeoJSON source/layer recipes.references/platform-setup.md — Deeper iOS/Android setup, token strategies, release signing notes.Official integration patterns for the Mapbox Maps Flutter SDK. Covers installation, iOS/Android platform setup, access token configuration, MapWidget initialization, camera control, annotations with tap handling, user location, and loading GeoJSON. Based on official Mapbox documentation.
The verbatim description from this skill’s front matter — the string an agent matches on to decide whether to load it.
main, last pushed 16 September 2026.SKILL.md, not by matching a directory convention. One layout observed: skills/*/SKILL.md.h1 and no skipped levels:.claude-plugin/marketplace.json by Mapbox Plugin Marketplace, declaring 1 plugin. It is read for editorial metadata only — never as the skill index, which is always the repository tree./mapbox/mapbox-agent-skills.md.md4 files · 15 KB
Everything this skill ships beside its prose. All of it is set here, as subchapters of skill 4.
Documentation the agent loads on demand, rather than up front.
Everything else published alongside the skill.