Skip to main content

Installation

Installing the SDK is a two-step process: add the package as a dependency in your Flutter project, then import it in your Dart source code. The SDK is published on pub.dev under the name b2metric_sdk, so the standard Flutter tooling handles the download, version resolution, and platform-specific setup automatically. No manual changes to Gradle, CocoaPods, or platform-level configuration files are required.

Step 1 — Add the Package

From the root directory of your Flutter project, run the following command:

flutter pub add b2metric_sdk

This command resolves the latest stable version of the SDK from pub.dev, adds it to your pubspec.yaml, and updates the lockfile. If you prefer to pin a specific version or manage dependencies manually, you can edit pubspec.yaml directly:

dependencies:
b2metric_sdk: ^1.0.0

After editing pubspec.yaml manually, fetch the dependency by running:

flutter pub get

Step 2 — Import the SDK

In any Dart file where you intend to use the SDK, import the package. A single import statement gives you access to all public classes including B2Metric, B2MetricConfig, LogLevel, and PushProvider:

import 'package:b2metric_sdk/b2metric_sdk.dart';
TIP

You typically only need to import the SDK in your application's entry point (where init() is called) and in any module that fires events. The SDK exposes a global singleton (B2Metric.instance), so you do not need to inject or pass it around your codebase.