The Official Amplitude Flutter plugin. Used to track events with Amplitude.

Getting Started

To use this plugin, add amplitude_flutter as a dependency in your pubspec.yaml file.

Find the API key for your Amplitude project under your project settings.

Import package:amplitude_flutter/amplitude_flutter.dart, and instantiate AmplitudeFlutter with your API key.

In addition, a Config object can be passed as a constructor argument for additional options.

NOTE: This plugin's methods should only be called from the main isolate.


import 'package:amplitude_flutter/amplitude_flutter.dart';

Future<void> example() async {
  final AmplitudeFlutter analytics =  AmplitudeFlutter('API KEY');

  // set this user's id

  // log an event
  analytics.logEvent(name: 'add_friend');

  // Log events with properties
  analytics.logEvent(name: 'add_friend', properties: { 'key': 'value' });

  // identify a user
  final Identify identify = Identify()
    ..set('cohort', 'Test A')
    ..setOnce('completed_onboarding', 'true')
    ..add('login_count', 1)
    ..append('tags', 'new tag')


  // Amplitude Accounts [] methods:
  // add a user to a group
  analytics.setGroup('orgId', 15);

  // change properties of a group
  analytics.groupIdentify('orgId', 15, Identify()..set('account_manager', 456));

  // emit an event associated with a group
  analytics.logEvent('Demo Released', properties: { 'groups': { 'orgId': 15 } });

  // Log revenue
  final Revenue revenue = Revenue()