The Flutter Agent monitors Flutter mobile applications. This page covers how to instrument the Flutter Agent in your Flutter application project.

Instrument the Flutter Agent

To instrument the Flutter Agent:

  1. Add the Flutter Agent to your project: 

    flutter pub add appdynamics_agent
    CODE
  2. Start the instrumentation at the start of the application (usually in main.dart):

    import 'package:appdynamics_agent/appdynamics_agent.dart';
      Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      final config = AgentConfiguration(
          appKey: <EUM_APP_KEY>,
    	  collectorURL: <URL>,
          loggingLevel: LoggingLevel.verbose // optional, for better debugging
    );
      await Instrumentation.start(config);
      runApp(const MyApp());
    }
    CODE
  3. (Android apps only) Add the following configurations:

    1. Add the following changes to android/build.gradle:

      dependencies {
      classpath "com.appdynamics:appdynamics-gradle-plugin:22.2.2"
      // ... other dependencies
      }
      CODE
    2. Apply the adeum plugin to the bottom of the android/app/build.gradle file: 

      dependencies {
      // ... project dependencies
      }
      
      // Bottom of file
      apply plugin: 'adeum'
      CODE
    3. Add the following permissions to your AndroidManifest.xml file (usually in android/src/main/):

      <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.myawesomepackage">
      
      <!-- add these two permissions -->
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      <application>
      <!-- other settings -->
      XML

Next Steps

To further customize how data is collected and reported, see Customize the Flutter Instrumentation.