firebase_performance 0.3.1+4

  • Readme
  • Changelog
  • Example
  • Installing
  • 98

Google Performance Monitoring for Firebase #

pub package

A Flutter plugin to use the Google Performance Monitoring for Firebase API.

For Flutter plugins for other Firebase products, see

Usage #

To use this plugin, add firebase_performance as a dependency in your pubspec.yaml file. You must also configure firebase performance monitoring for each platform project: Android and iOS (see the example folder or for step by step details).

You can confirm that Performance Monitoring results appear in the Firebase console. Results should appear within 12 hours.

Define a Custom Trace #

A custom trace is a report of performance data associated with some of the code in your app. To learn more about custom traces, see the Performance Monitoring overview.

final Trace myTrace = FirebasePerformance.instance.newTrace("test_trace");

final Item item = cache.fetch("item");
if (item != null) {
  myTrace.incrementMetric("item_cache_hit", 1);
} else {
  myTrace.incrementMetric("item_cache_miss", 1);


Add monitoring for specific network requests #

Performance Monitoring collects network requests automatically. Although this includes most network requests for your app, some might not be reported. To include specific network requests in Performance Monitoring, add the following code to your app:

class _MetricHttpClient extends BaseClient {

  final Client _inner;

  Future<StreamedResponse> send(BaseRequest request) async {
    final HttpMetric metric = FirebasePerformance.instance
        .newHttpMetric(request.url.toString(), HttpMethod.Get);

    await metric.start();

    StreamedResponse response;
    try {
      response = await _inner.send(request);
        ..responsePayloadSize = response.contentLength
        ..responseContentType = response.headers['Content-Type']
        ..requestPayloadSize = request.contentLength
        ..httpResponseCode = response.statusCode;
    } finally {
      await metric.stop();

    return response;

class _MyAppState extends State<MyApp> {
  Future<void> testHttpMetric() async {
    final _MetricHttpClient metricHttpClient = _MetricHttpClient(Client());

    final Request request =
        Request("SEND", Uri.parse(""));


Getting Started #

See the example directory for a complete sample app using Google Performance Monitoring for Firebase.

Issues and feedback #

Please file Flutterfire specific issues, bugs, or feature requests in our issue tracker.

Plugin issues that are not specific to Flutterfire can be filed in the Flutter issue tracker.

To contribute a change to this plugin, please review our contribution guide, and send a pull request.

0.3.1+4 #

  • Skip flaky driver tests.

0.3.1+3 #

  • Fixed analyzer warnings about unused fields.

0.3.1+2 #

  • Updated README instructions for contributing for consistency with other Flutterfire plugins.

0.3.1+1 #

  • Remove AndroidX warning.

0.3.1 #

  • Support v2 embedding. This will remain compatible with the original embedding and won't require app migration.

0.3.0+5 #

  • Update documentation to reflect new repository location.
  • Update unit tests to call TestWidgetsFlutterBinding.ensureInitialized.

0.3.0+4 #

  • Update google-services Android gradle plugin to 4.3.0 in documentation and examples.

0.3.0+3 #

  • Fix bug that caused invokeMethod to fail with Dart code obfuscation

0.3.0+2 #

  • Fix bug preventing this plugin from working with hot restart.

0.3.0+1 #

  • Automatically use version from pubspec.yaml when reporting usage to Firebase.

0.3.0 #

  • Breaking Change Removed Trace.incrementCounter. Please use Trace.incrementMetric.
  • Assertion errors are no longer thrown for incorrect input for Traces and HttpMetrics.
  • You can now get entire list of attributes from Trace and HttpMetric with getAttributes().
  • Added access to Trace value name.
  • Added access to HttpMetric values url and HttpMethod.

0.2.0 #

  • Update Android dependencies to latest.

0.1.1 #

  • Deprecate Trace.incrementCounter and add Trace.incrementMetric.
  • Additional integration testing.

0.1.0+4 #

  • Remove deprecated methods for iOS.
  • Fix bug where Trace attributes were not set correctly.

0.1.0+3 #

  • Log messages about automatic configuration of the default app are now less confusing.

0.1.0+2 #

  • Fixed bug where Traces and HttpMetrics weren't being passed to Firebase on iOS.

0.1.0+1 #

  • Log a more detailed warning at build time about the previous AndroidX migration.

0.1.0 #

  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.

0.0.8+1 #

  • Bump Android dependencies to latest.

0.0.8 #

  • Set http version to be compatible with flutter_test.

0.0.7 #

  • Added missing http package dependency.

0.0.6 #

  • Bump Android and Firebase dependency versions.

0.0.5 #

Added comments explaining the time it takes to see performance results.

0.0.4 #

  • Formatted code, updated comments, and removed unnecessary files.

0.0.3 #

  • Updated Gradle tooling to match Android Studio 3.1.2.

0.0.2 #

  • Added HttpMetric for monitoring for specific network requests.

0.0.1 #

  • Initial Release.


firebase_performance_example #

Demonstrates how to use the firebase_performance plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  firebase_performance: ^0.3.1+4

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:firebase_performance/firebase_performance.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
e2e ^0.2.1
firebase_core ^0.4.0
http ^0.12.0
test any