Flutter SDK Overview | Urbi Documentation
Flutter SDK

Flutter SDK

Flutter SDK allows you to add an 2GIS map to your application. Using the SDK, you can display a map on the screen, get information about map objects, use the navigator, build routes, and so on.

See SDK usage examples in the Examples section.

Geodata complies with OGC standards.

You can use Flutter SDK on devices with iOS and Android operating systems.

Flutter SDK packages are available in pub.dev in two versions:

  • Full is a full version that allows you to:
    • Add a map to the application and manage it: add markers and geometric shapes, control the camera movement, display layers (for example, traffic), work with map styles, etc.
    • Search for objects in the directory: organizations, buildings, places, and others.
    • Work with the navigator in the application in one of the three modes: free-drive, turn-by-turn, or simulated navigation.
    • Build optimal routes on ​​the map, including routes inside buildings.
    • Use offline data.
  • Map is a lightweight version that allows you to:
    • Add a map to the application and manage it: add markers and geometric shapes, control the camera movement, display layers (for example, traffic), work with map styles, etc.
    • Search for objects in the directory: organizations, buildings, places, and others.

Important

You cannot use Full and Map simultaneously. It causes an assembly error.

To work with the SDK, you need to get a key file dgissdk.key. It allows connecting to 2GIS servers and retrieving the geographical data, as well as using offline data and the navigator. To obtain the key file, fill in the form at dev.2gis.com and specify the appId of the application for which the key is created.

After you receive the key, initialize the SDK. Follow the requirements:

  • You can initialize the SDK only once per application. Only one key can be used for each application. Different keys are required in the following cases:
    • If the application is available for different operating systems.
    • If the application has several alternatives for a single OS (for example, one application for the driver and another for the passenger).
    • If different SDK versions are used (Full and Map).
  • The appId value of the application must match the app_id value in the key file.
  • Changing the key file while the application is running is not supported.

Some SDK features use search and navigation APIs. Access to these APIs is provided with the SDK key. API usage is paid additionally, depending on the number of sent requests (and in some cases, on the number of received responses). See the list of features and additional APIs below.

You can check the statistics of API request distribution in the Platform Manager.

Feature
APIs
Creating a search engine
(SearchManager class)
Regions API
Getting search results
(SearchManager.search method)
Access to certain information about objects is only available with additional key configuration for an extra fee: see the Object data structure section.
Searching for objects in the directory by ID
(SearchManager.searchById method)
Building search suggestions
(SearchManager.suggest method)
Suggest API
Searching for an optimal route considering traffic jams
(TrafficRouter class)
Starting the navigation (NavigationManager.start method):
Searching for alternative routes
(AlternativeRouteSelector class)
Displaying routes on the map
(RouteEditorSource class)
Displaying traffic jams on the map
(TrafficSource class)
Regions API
Displaying road events
(RoadEventSource) class
Regions API
Calculating the device geolocation based on cell towers and nearest Wi-Fi access points
(using RadarApiSettings in Android and ru.dgis.sdk.positioning.RadarSettingsProvider)
Radar API

To install the Flutter SDK on iOS and Android, add one of the following dependencies to your pubspec.yaml file.

  • For the Full SDK version:

    dependencies:
        flutter:
            sdk: flutter
        flutter_localizations:
            sdk: flutter
    
        dgis_mobile_sdk_full:
            # When depending on this package from a real application you should use:
            #   dgis_mobile_sdk_full: ^x.y.z
            # See https://dart.dev/tools/pub/dependencies#version-constraints
            # The example app is bundled with the plugin so we use a path dependency on
            # the parent directory to use the current plugin's version.
            path: ../
    }
    
  • For the Map SDK version:

    dependencies:
        flutter:
            sdk: flutter
    
        dgis_mobile_sdk_map:
            # When depending on this package from a real application you should use:
            #   dgis_mobile_sdk_map: ^x.y.z
            # See https://dart.dev/tools/pub/dependencies#version-constraints
            # The example app is bundled with the plugin so we use a path dependency on
            # the parent directory to use the current plugin's version.
            path: ../
    

For full file examples, see the GitHub repository: pubspec.yaml.

Follow additional installation steps for Android.

A binary artifact in the .aar format is used when building for Android. To connect correctly, add a repository with this artifact to build.gradle of your application:

repositories {
    maven {
        url "https://artifactory.2gis.dev/sdk-maven-release"
    }
}