Installation and initialization
To integrate AppMetrica into Flutter, use the AppMetrica SDK for Flutter plugin:
Install the AppMetrica SDK for Flutter plugin in your project. From the root of the project, run the command:
flutter pub add appmetrica_plugin
Copied to clipboardAfter adding the plugin, you'll see a line with the following dependency in the
pubspec.yaml
file:dependencies: appmetrica_plugin: ^1.3.0
Copied to clipboard- Add
appmetrica_plugin
import:import 'package:appmetrica_plugin/appmetrica_plugin.dart';
Copied to clipboard Initialize the AppMetrica library using
AppMetrica.activate
and your API key:AppMetrica.activate(AppMetricaConfig("insert_your_api_key_here"));
Copied to clipboardSend an event using
AppMetrica.reportEvent
to test the operation:AppMetrica.reportEvent('My first AppMetrica event!');
Copied to clipboard