Skip to content

Flutter Application Integration


Collect metrics data from various Flutter applications and analyze application performance visually.

Reading Path

Prerequisites

Note: If you have enabled the RUM Headless service, the prerequisites are automatically configured for you. You can directly integrate the application.

Application Integration

Note

The current Flutter version only supports Android and iOS platforms.

  1. Go to RUM > Create > Android/iOS
  2. Create two applications for Flutter Android and Flutter iOS respectively, to receive RUM data from the Android and iOS platforms separately
  3. Enter the corresponding application name and application ID for each platform's application
  4. Choose the application integration method:

    • Public Network DataWay: Directly receives RUM data without installing the DataKit collector
    • Local Environment Deployment: Receives RUM data after meeting the prerequisites

Installation

Pub.Dev: ft_mobile_agent_flutter

Source Code Address: https://github.com/TrueWatchTech/datakit-flutter

Demo Address: https://github.com/TrueWatchTech/datakit-flutter/example

Execute the following command in your project directory:

flutter pub add ft_mobile_agent_flutter

This will add the dependency in your package's pubspec.yaml:

dependencies:
  ft_mobile_agent_flutter: [latest_version]

  # For Flutter 2.0 compatibility, use the following reference method
  ft_mobile_agent_flutter:
    git:
url: https://github.com/TrueWatchTech/datakit-flutter.git
ref: [github_legacy_lastest_tag]

Import it in your Dart code:

import 'package:ft_mobile_agent_flutter/ft_mobile_agent_flutter.dart';

Additional Configuration for Android Integration

  • Configure the Gradle Plugin ft-plugin for collecting App launch events, and Android Native-related events (page navigation, click events, Native network requests, WebView data)
  • To count launch times and measure launch duration, you need to customize the Application and declare it in AndroidManifest.xml
import io.flutter.app.FlutterApplication

/**
 * If you need to count [Launch Times] and [Launch Duration], add a custom Application here
 */
class CustomApplication : FlutterApplication() {
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.ft.sdk.flutter.agent_example">
  <application android:name=".CustomApplication">
    //...
  </application>
</manifest>

Detailed Configuration Entries

Advanced Scenarios

Conflict Field Description

  • Special key: track_id, used for tracking functionality
  • When a user adds a custom tag via globalContext that conflicts with an SDK's built-in tag, the SDK's tag value will override the user-set value
  • It is recommended to add a project abbreviation prefix to tag names, e.g., custom_tag_name

  • The key values used in the project can be referenced from the Android constant definitions: Constants.java

Frequently Asked Questions