User Guide: SDKs > Flutter SDK > Initializing the Flutter SDK
Initializing the Flutter SDK
To use any Volt Foundry SDK functions, you must add
import 'package:voltmx_sdk_flutter/voltmx_sdk_flutter.dart';
to your files. You must use the following code snippet to initialize the SDK Client before using any services.
// Sample code to initialize Volt Foundry Client
var voltmxSdkFlutter = VoltmxSdkFlutter();
var appKey = "<Your appKey here>";
var appSecret = "<Your appSecret here>";
var serviceURL = "<Your serviceURL here>";
voltmxSdkFlutter.initializeSDK(appKey, appSecret, serviceURL, onSuccess: (response) {
// Handle the success case here
}, onFailure: (response) {
// Handle the failure case here
});
Note : Only upon successful completion of voltmxSdkFlutter.initializeSDK method, you can call the other methods in the SDK, such as Identity Service, Integration Service, Messaging Service, Metrics Service, and Object Service.
As the voltmxSdkFlutter.initializeSDK method is an asynchronous call, you must wait until the background process to be completed before you call the other methods in the SDK. If you attempt to call any other methods in the SDK before the initialization method completion, the system will not allow you to call the methods and it throws an exception.
When the SDK is initialized, the Volt MX SDK registers a session and sends its information to the Volt Foundry Server. If the device is offline or the server is not reachable, the session information persists on the device until it can successfully send the information to the Volt Foundry server.