• English日本語한국어
  • Log inStart now

Monitor your Flutter app

Monitor your Flutter application with our New Relic Flutter agent. Capture Dart errors, track specific network requests, use distributed tracing to drill down into handled exceptions, and create custom tracking events and metrics to fully capture your end users' experience.

Summary view of a flutter app in New Relic

one.newrelic.com > Mobile > (select an app) > Summary: View Flutter data, track HTTP requests and errors, and monitor how your app is performing over time.

Ready to get started? Follow the steps below!

Install the Flutter agent

Step 1 of 5

Review the requirements

Before you install the Flutter agent, make sure your Flutter app meets these version requirements:

  • Flutter 2.5.0 or higher
  • Dart versions 2.16.2 or higher, up to but not including 3.0.0

For Android-native apps:

For iOS-native apps:

Step 2 of 5

Add the Flutter agent to your project

First, you'll need to add the Flutter agent into your dart project. In your pubspec.yaml, add the following to dependencies:

dependencies:
newrelic_mobile: 0.0.1
Step 3 of 5

Copy your application token

The application token is used for New Relic to authenticate your Flutter app's data.

To view and copy your application token in the New Relic UI:

  1. Go to one.newrelic.com, click Add data, then click Mobile.
  2. Select your Flutter app.
  3. Go to Settings > Application and copy the displayed Application token.

You'll add this application token in the next step.

Step 4 of 5

Configure your Flutter project

In your Flutter project, open main.dart and add the following code:

import 'package:newrelic_mobile/newrelic_mobile.dart';
var appToken = "";
if (Platform.isAndroid) {
appToken = "<android app token>"; // Replace with your application token copied from the New Relic UI.
} else if (Platform.isIOS) {
appToken = "<ios app token>"; // Replace with your application token copied from the New Relic UI.
}
Config config =
Config(accessToken: appToken,
//Android Specific
// Optional: Enable or disable collection of event data.
analyticsEventEnabled: true,
// Optional: Enable or disable reporting successful HTTP requests to the MobileRequest event type.
networkErrorRequestEnabled: true,
// Optional: Enable or disable reporting network and HTTP request errors to the MobileRequestError event type.
networkRequestEnabled: true,
// Optional: Enable or disable crash reporting.
crashReportingEnabled: true,
// Optional: Enable or disable interaction tracing. Trace instrumentation still occurs, but no traces are harvested. This will disable default and custom interactions.
interactionTracingEnabled: true,
// Optional: Enable or disable capture of HTTP response bodies for HTTP error traces and MobileRequestError events.
httpResponseBodyCaptureEnabled: true,
// Optional: Enable or disable agent logging.
loggingEnabled: true,
// iOS specific
// Optional: Enable or disable automatic instrumentation of WebViews
webViewInstrumentation: true,
//Optional: Enable or disable Print Statements as Analytics Events
printStatementAsEventsEnabled : true,
// Optional: Enable or disable automatic instrumentation of HTTP Request
httpInstrumentationEnabled:true
);
NewrelicMobile.instance.start(config, () {
runApp(MyApp());
});
class MyApp extends StatelessWidget {
....

Make sure you pasted your application token(s) (copied from Step 3) into appToken = "" in the code above. If you're monitoring both Android-native and iOS-native apps, you'll need to add separate tokens for both.

Step 5 of 5

(Android-only) Configure your Android app

If you have an Android-native app, you'll need make the following changes in your Android app:

  1. Add the following changes to your app's android/build.gradle file:
buildscript {
...
repositories {
...
mavenCentral()
}
dependencies {
...
classpath "com.newrelic.agent.android:agent-gradle-plugin:${latest_android_version}"
}
}
  1. Apply the newrelic plugin to the top of your android/app/build.gradle file:
apply plugin: "com.android.application"
apply plugin: 'newrelic' // <-- add this
  1. Add INTERNET and ACCESS_NETWORK_STATE permissions in your AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

And you're done! You should start seeing data in New Relic within 5 minutes.

View your Flutter app data in New Relic

Now that you've got the Flutter agent sending data to New Relic, it's time to view your app data in New Relic.

Go to one.newrelic.com > Mobile > (select your Flutter app) > Summary to see a summary of your data over time.

With the Flutter agent, you have access to all mobile monitoring features, such as tracking crashes, HTTP requests, and handled exceptions. Check out these feature pages for more info:

Troubleshoot missing data in the UI

Having trouble finding HTTP data in the UI?

Problem

After installing the Flutter agent and waiting at least 5 minutes, No HTTP data appears: on the HTTP errors and HTTP requests UI pages.

Solution

If no HTTP data appears after you wait at least five minutes, check you are not overriding HttpOverrides.global inside your Flutter app.

Query Flutter log data

New Relic stores your Flutter logs as custom events. You can query these logs and build dashboards for them using this NRQL query:

SELECT * FROM Mobile Dart Console Events SINCE 30 MINUTES AGO

For more information on NRQL queries, see Introduction to NRQL.

(Optional) Customize the Flutter agent instrumentation

Check out these optional API calls to further customize how New Relic collects and reports data:

Use the iOS or Android SDK APIs to create custom events and metrics. Here are some examples:

Copyright © 2023 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.