Skip to content

AppAmbit: Getting Started with Flutter

This guide walks you through setting up the AppAmbit Flutter SDK in your application, focusing on AppAmbit Analytics and Crash Reporting.

1. Prerequisites

Before getting started, ensure you meet the following requirements:

  • Visual Studio Code or a Code Editor
  • Flutter SDK >=3.3.0
  • Dart SDK >=3.9.0
  • Android SDK with:
    • Android 5.0+
    • compileSdkVersion 34
    • targetSdkVersion 34
    • minSdkVersion 21
  • iOS SDK with:
    • Xcode 15+ (for iOS)
    • macOS 13+

2. Creating Your App in the AppAmbit Portal

  1. Visit AppAmbit.com.
  2. Sign in or create an account. Navigate to "Apps" and click on "New App".
  3. Provide a name for your app. Optionally, upload an image via drag-and-drop.
  4. Select the appropriate release type and select the OS.
  5. Click "Create" to generate your app.
  6. Retrieve the App Key from the app Info page.

3. Adding AppAmbit Flutter SDK modules

You can install the Flutter SDK from either:

Pub.dev (recommended) — easiest to keep up-to-date

GitHubReleases — direct download of tagged code

  1. To install the library you can run the following flutter command

Dart

flutter pub add appambit_sdk_flutter

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  appambit_sdk_flutter: ^0.0.1

4. Initializing Flutter SDK

1 - Add the following line inside the main.dart callback of your app's main class to use AppAmbit

Dart

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  AppambitSdk.start(appKey: '<YOUR-APPKEY>');

  runApp(const MyApp());
}

Warning

It is not recommended to insert the secret apikey directly into the code.

2 - Visual Studio Code automatically suggests the necessary import statements once you insert the start() method, but if you see an error indicating that the class names are not recognized, add the following line to the import statements of the class:

Dart

import 'package:appambit_sdk_flutter/appambit_sdk_flutter.dart';

This code automatically generates a session, the session management is automatic.