Flutter Native - Getting started
This guide walks you through installing and configuring the Wemap Flutter SDK, and displaying your first map.
Prerequisites
Before you begin, ensure you have the following:
| Requirement | Version |
|---|---|
| Flutter | 3.35.0 or higher |
| Dart SDK | >= 3.9.0 < 4.0.0 |
| Android | minSdkVersion 24 |
| iOS | 13.0 or higher |
You'll also need:
- A valid Map ID and token — contact Wemap if you do not have them yet
The Flutter package is on pub.dev.
Installation
Add the dependency
Add the SDK to your pubspec.yaml:
dependencies:
wemap_sdk_flutter: ^0.29.0
Or install via command line:
flutter pub add wemap_sdk_flutter
Then fetch dependencies:
flutter pub get
Platform setup
Android
- Add repository — In
android/build.gradle, add the Wemap Maven repository inside theallprojects→repositoriesblock:
- Groovy DSL
- Kotlin DSL
allprojects {
repositories {
google()
mavenCentral()
// Wemap Maven repository
maven {
url "https://s3.eu-west-1.amazonaws.com/mobile.getwemap.com/releases/android"
}
}
}
allprojects {
repositories {
google()
mavenCentral()
// Wemap Maven repository
maven {
url = uri("https://s3.eu-west-1.amazonaws.com/mobile.getwemap.com/releases/android")
}
}
}
- Set minSdkVersion — In
android/local.properties:
flutter.minSdkVersion=24
- Use minSdkVersion in app — In
android/app/build.gradle, insidedefaultConfig:
- Groovy DSL
- Kotlin DSL
defaultConfig {
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
// ... other config
}
defaultConfig {
minSdk = localProperties.getProperty("flutter.minSdkVersion").toInt()
// ... other config
}
iOS
The plugin supports Swift Package Manager (SPM) and CocoaPods. Prefer SPM when you can.
Option A — Swift Package Manager (recommended)
Enable SPM for your Flutter app (per project):
# pubspec.yaml
flutter:
config:
enable-swift-package-manager: true
Or globally:
flutter config --enable-swift-package-manager
Set the iOS deployment target to 13.0 or higher, then run flutter pub get and build. No Wemap CocoaPods sources or extra gems are required for this path.
Option B — CocoaPods
- Add sources to Podfile — At the top of
ios/Podfile:
source 'https://cdn.cocoapods.org/'
source 'https://github.com/wemap/cocoapods-specs.git'
- Set platform version:
platform :ios, '13.0'
- Enable BUILD_LIBRARY_FOR_DISTRIBUTION — Add or update the
post_installblock:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
- Install gems — Create a
Gemfilein the project root:
source 'https://rubygems.org'
gem 'cocoapods'
gem 'cocoapods-s3-download'
Then run bundle install and cd ios && pod install. When upgrading an existing install, use pod update.
Your first map
Here is a minimal example that displays a Wemap map:
import 'package:flutter/material.dart';
import 'package:wemap_sdk_flutter/wemap_sdk_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Wemap Sample')),
body: const MapScreen(),
),
);
}
}
class MapScreen extends StatelessWidget {
const MapScreen({super.key});
void _onMapReady(MapData mapData, MapManager mapManager) {
debugPrint('Map ready: ${mapData.id}');
}
Widget build(BuildContext context) {
return WemapMap(
options: MapOptions(
mapID: yourMapId, // Replace with your Wemap map ID
token: yourToken, // Replace with your token
environment: Environment.PROD,
),
onMapReady: _onMapReady,
);
}
}
Required options
Only three options are required to display a map:
mapID— Your Wemap map identifier (integer)token— Authentication tokenenvironment—Environment.PRODorEnvironment.DEV
Everything else (location source, offline mode, VPS settings, etc.) has sensible defaults and is covered in Part 2.
Run the app
flutter run
You should see the map load with the default view. The onMapReady callback is called when the map data is loaded and the map is interactive.
Troubleshooting
| Issue | Solution |
|---|---|
pub get fails | Use wemap_sdk_flutter from pub.dev (flutter pub add wemap_sdk_flutter), then flutter pub get |
| Android build fails | Verify the Wemap Maven repository is added in android/build.gradle and the device has network access |
| iOS / SPM build fails | Confirm enable-swift-package-manager: true (or Flutter SPM is enabled), then flutter clean and flutter pub get |
iOS pod install fails (CocoaPods) | Run bundle install first; ensure cocoapods-s3-download is installed and Wemap pod sources are in the Podfile |
| Map does not load | Check your Map ID and token are valid and the device has network access |
For more help, visit developers.getwemap.com or contact Wemap.