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 Wemap account and a valid Map ID
- Credentials (access key, secret key, region) from the Wemap team — contact Wemap to obtain them
Installation
1. Configure credentials
The Wemap SDK is distributed via a private package host. Set these environment variables with the credentials provided by Wemap:
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=your_region
Note: You must provide your Flutter team email to Wemap to receive permissions for the SDK.
2. Add the dependency
Log in to the package host using the same email you provided to Wemap:
dart pub global activate onepub
onepub login
Add the SDK to your pubspec.yaml:
dependencies:
wemap_sdk_flutter:
hosted: https://onepub.dev/api/supddavuhn
version: ^0.27.0
Or install via command line:
onepub pub add wemap_sdk_flutter
Then fetch dependencies:
flutter pub get
Platform setup
Android
- Add repositories — In
android/build.gradle, add these repositories inside theallprojects→repositoriesblock:
- Groovy DSL
- Kotlin DSL
allprojects {
repositories {
// ... existing repositories
maven { url "https://dist.nao-cloud.com/android/maven/" }
maven {
url "s3://mobile-dev.getwemap.com/wemap/sdk/android"
credentials(AwsCredentials) {
accessKey String.valueOf(System.getenv("AWS_ACCESS_KEY_ID"))
secretKey String.valueOf(System.getenv("AWS_SECRET_ACCESS_KEY"))
}
}
}
}
allprojects {
repositories {
maven {
url = uri("https://dist.nao-cloud.com/android/maven/")
}
maven {
url = uri("s3://mobile-dev.getwemap.com/wemap/sdk/android")
credentials(AwsCredentials::class) {
accessKey = System.getenv("AWS_ACCESS_KEY_ID")
secretKey = System.getenv("AWS_SECRET_ACCESS_KEY")
}
}
}
}
- 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
- 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.
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 | Ensure credentials are set and you've logged in with onepub login |
| Android build fails | Verify AWS credentials are available to Gradle (same shell or CI secrets) |
iOS pod install fails | Run bundle install first; ensure cocoapods-s3-download gem is installed |
| Map does not load | Check your Map ID is valid and the device has network access |
For more help, visit developers.getwemap.com or contact Wemap.