Skip to main content

Flutter Native - Getting started

Installation

Before starting to develop your application with the WemapSDKs, you'll need to configure your credentials and add the SDK as a dependency.

Configure credentials

Wemap provides WemapSDKs via a private host and you will need to get secret, access keys and region to be able to access it. For additional information contact Wemap team.

Once you get the credentials, specify AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION in your environment

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_REGION=...

then you will send us your flutter team email, so you get permissions to use the SDK

Add the dependency

firstly login with the same email you have provided us:

dart pub global activate onepub
onepub login

Add the WemapSDKs to your app by adding in pubspec.yaml file:

wemap_sdk_flutter:
hosted: https://onepub.dev/api/supddavuhn
version: 0.3.0

Or by cmd:

onepub pub add wemap_sdk_flutter
  • And then you can bootstrap dependencies using:
flutter pub get

Android

  • Add this two repositories to repositories block inside allprojects in android/build.gradle:
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"))
}
}
  • Add the minSdkVersion to local.properties:
flutter.minSdkVersion=21
  • In your app/build.gradle set the minSdkVersion inside defaultConfig section to:
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
  • If you want use VPS to access user location, you have to add into AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />

iOS

  • Add to Podfile head:
source 'https://cdn.cocoapods.org/'
source 'https://github.com/wemap/cocoapods-specs.git'
  • (also in Podfile) Set BUILD_LIBRARY_FOR_DISTRIBUTION to true:
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
  • If you want use VPS to access user location, you have to add into Info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSCameraUsageDescription</key>
<string></string>

and this into Podfile since permission_handler package is used :

config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',

## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',
]

Add a map

  • You can simply add the Livemap widget as follow:
import 'package:flutter/material.dart';
import 'package:wemap_sdk_flutter/wemap_sdk_flutter.dart';

void main() {
runApp(const MyHomePage(
title: 'wemap sample',
));
}

class MyHomePage extends StatelessWidget {
final String title;

const MyHomePage({super.key, required this.title});

void _onMapReady(MapData mapData, MapManager livemapManager) {
// what ever to do, the map is ready
}

void _onBuildingFocusChanged(Building? building) {
// print("on Building focus changed");
}

void _onActiveLevelChanged(Building building, Level level) {
// print("on active level changed");
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text(title)),
body: Container(
constraints: const BoxConstraints.expand(),
child: WemapMap(
options: MapOptions(
mapID: 25669, token: "", environment: Environment.PROD),
onMapReady: _onMapReady,
onActiveLevelChanged: _onActiveLevelChanged,
onBuildingFocusChanged: _onBuildingFocusChanged,
))));
}
}