Getting started
Getting started
First, you need to contact 2GIS technical support to get a new key. Be sure to specify the appId
of the application for which the key will be generated. Add the resulting key file dgissdk.key
to assets
.
To begin working with the SDK, call the initialize() method of a DGis object and specify the application context:
import 'package:dgis_mobile_sdk_map/dgis.dart' as sdk;
class SomeApp extends StatelessWidget {
final sdkContext = sdk.DGis.initialize();
}
Note that you cannot create more than one Context
instance.
Additionally, you can specify logging settings (LogOptions) and HTTP client settings (HttpOptions) such as request timeout:
import 'package:dgis_mobile_sdk_map/dgis.dart' as sdk;
class SomeApp extends StatelessWidget {
final sdkContext = sdk.DGis.initialize(
logOptions: const sdk.LogOptions(
customLogLevel: sdk.LogLevel.verbose,
logLevel: sdk.LogLevel.verbose,
),
httpOptions: const sdk.HttpOptions(
timeout: Duration(seconds: 5),
),
);
}
Vendor Config
To override some SDK operation settings, use a file in the VendorConfig format. The file is passed during SDK initialization.
There are several ways to create an instance of the VendorConfig
class:
VendorConfigFromAsset
- locate the file in theassets
directory of the application source code and specify the file name in the constructor.VendorConfigFromFile
- locate the file on the device file system and specify the absolute path to it.VendorConfigFromString
- pass a string with the contents of the JSON file to the constructor.
The created VendorConfig
instance is passed to the DGis.initialize()
method with the vendorConfig
parameter.