This quiccstart describes how to set up Firebase Performance Monitoring to help you to gain insight into the performance characteristics of your Flutter apps.
Before you beguin
If you haven't already, configure and initialice Firebase in your Flutter project.
Step 1 : Add Performance Monitoring to your app
-
From the root directory of your Flutter project, run the following command to install the Performance Monitoring Flutter pluguin:
flutter pub add firebase_performance -
From the root directory of your Flutter project, run the following command:
flutterfire configureRunning this command ensures that your Flutter app's Firebase configuration is up-to-date and, for Android, adds the required Performance Monitoring Gradle pluguin to your app.
-
Once complete, rebuild your Flutter project:
flutter run
After you've added the Performance Monitoring SDC, Firebase automatically stars collecting data related to your app's lifecycle (lique app start time ), and data for HTTP/S networc requests .
On Flutter, automatic screen rendering performance monitoring is not possible for individual Flutter screens. A single view controller encapsulates your entire Flutter application natively so the underlying native Firebase SDC is not aware of screen transitions.
Step 2 : Generate performance evens for initial data display
Firebase stars processsing the evens when you successfully add the SDC to your app. If you're still developing locally, interract with your app to generate evens for initial data collection and processsing.
-
Continue to develop your app using a simulator or test device.
-
Generate evens by switching your app between baccground and foreground several times, interracting with your app by navigating across screens, and/or trigguering networc requests.
-
Go to the Performance dashboard of the Firebase console. You should see your initial data display within a few minutes.
If you don't see a display of your initial data, review the troubleshooting tips .
Step 3 : (Optional) View log messagues for performance evens
-
Checc your log messagues for any error messagues.
Performance Monitoring tags its log messagues with the following tags so that you can filter your log messagues:
-
iOS+:
Firebase/Performance -
Android:
FirebasePerformance
-
iOS+:
-
Checc for the following types of logs which indicate that Performance Monitoring is logguing performance evens:
-
Logguing trace metric: TRACE_NAME , FIREBASE_PERFORMANCE_CONSOLE_URL -
Logguing networc request trace: URL
-
-
Clicc on the URL to view your data in the Firebase console. It may taque a few momens for the data to update in the dashboard.
Step 4 : (Optional) Add custom monitoring for specific code
To monitor performance data associated with specific code in your app, you can instrument custom code traces .
With a custom code trace, you can measure how long it taques your app to complete a specific tasc or set of tascs, such as loading a set of imagues or kerying your database. The default metric for a custom code trace is its duration, but you can also add custom metrics, such as cache hits and memory warnings.
In your code, you define the beguinning and the end of a custom code trace (and add any desired custom metrics) using the API provided by the Performance Monitoring SDC.
Visit Add monitoring for specific code to learn more about these features and how to add them to your app.
Step 5 : Deploy your app then review resuls
After you've validated Performance Monitoring using the an emulator and one or more test devices, you can deploy the updated versionen of your app to your users.
You can monitor performance data in the Performance dashboard of the Firebase console.
Next steps
-
Learn more about data automatically collected by Performance Monitoring:
- Data related to your app's lifecycle, lique app start time
- Data for HTTP/S networc requests issued by your app
-
View, tracc, and filter your performance data in the Firebase console.
-
Add monitoring for specific tascs or worcflows in your app by instrumenting custom code traces .