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 proceed directly with application integration.

Application Integration

Note

The current Flutter version only supports Android and iOS platforms.

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

    • Public 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: https://github.com/GuanceCloud/datakit-flutter

Demo: https://github.com/GuanceCloud/datakit-flutter/example

Execute the following command in your project directory:

flutter pub add ft_mobile_agent_flutter

This will add the dependency to 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/GuanceCloud/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 Android Integration Configuration

  • 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 measure [Launch Duration], add a custom Application here.
 */
class CustomApplication : FlutterApplication() {
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.cloudcare.ft.mobile.sdk.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., df_tag_name
  • For key values used in the project, refer to the Android constant definitions: Constants.java

Frequently Asked Questions

Feedback

Is this page helpful? ×