Skip to content

Environment Setup - Flutter Examples

In this guide you will learn how to set up your environment to run the Flutter examples.

Create Your Account

First, create your Magic Lane account and get your API key token. See the Getting Started guide.

Install Flutter

Follow the instructions to install Flutter by visiting the official documentation:

Flutter Install

Download Examples

Download the Flutter examples ZIP file or clone the repository using git.

Maps SDK Examples for Flutter

After downloading the examples, you will have a file like this:

maps-sdk-examples-for-flutter-master.zip

Download the SDK

Download the Maps SDK for Flutter:

Maps SDK for Flutter

Extract the SDK

Unzip the downloaded file and look for the gem_kit folder. This is the Flutter SDK.

Move the SDK Directory

Move the gem_kit directory into the plugins subdirectory of the example you wish to run, such as hello_map/plugins.

cd MAGICLANE-MAPS-SDK-Flutter*
mv gem_kit ../maps-sdk-examples-for-flutter-master/hello_map/plugins
cd MAGICLANE-MAPS-SDK-Flutter*
move gem_kit ..\maps-sdk-examples-for-flutter-master\hello_map\plugins

Build and Run

Now that Flutter is installed, and you have moved the gem_kit directory to the plugins directory of the example you want to run, you are ready to build and run the example.

Hello map - example Flutter screenshot

Run the example:

flutter run

Set the API Key Token

Within the project directory, such as hello_map, go to the lib subdirectory and edit the main.dart source code file. The main() function, where code execution starts, is shown below.

1Future<void> main() async {
2  const String projectApiToken = "YOUR_API_KEY_TOKEN";
3  await GemKit.initialize(appAuthorization: projectApiToken);
4  runApp(const MyApp());
5}

Replace the YOUR_API_KEY_TOKEN string with your actual API key, save the file, and run the example again.

Note

Although it is also possible to set your API key token string as an environment variable, setting it directly in the code is more secure.