Exa Performance Flutter Library

The exa_performance_flutter library provides performance monitoring capabilities for Flutter applications, leveraging Firebase Performance Monitoring.

Installation

To use this library in your Flutter project, add the following dependency to your pubspec.yaml file:

dependencies:
  exa_performance_flutter: ^0.0.1  # (Replace with the latest version)

Then, run flutter pub get to fetch the package.

Usage

To get started with the Exa Performance library, follow these steps:

  1. Import the library in your Dart file:
import 'package:exa_performance_flutter/exa_performance_flutter.dart';
  1. Initialize the ExaPerformance instance:
ExaPerformance exaPerformance = ExaPerformance();
  1. Use the performance monitoring functions provided by the library. For example:
// Test network performance with default GET method
await exaPerformance.testNetwork('https://example.com/api');

// Test network performance with custom attributes and POST method
await exaPerformance.testNetwork(
  'https://example.com/api',
  attributes: {'key': 'value'},
  method: RequestMethodEnum.POST,
);

// Test a custom trace
await exaPerformance.testTrace('custom_trace', function: () {
  // Your code here
});

// Start render metric for a screen
await exaPerformance.startRenderMetric(screenName: 'example_screen');

// Stop render metric
await exaPerformance.stopRenderMetric();

Functions

testNetwork

Future<void> testNetwork(
  String url, {
  Map<String, String>? attributes,
  RequestMethodEnum method = RequestMethodEnum.GET,
});

Tests the network performance for a given URL with optional attributes.

testTrace

Future<void> testTrace(String name, {Function()? function});

Tests a custom trace with an optional function to measure.

startRenderMetric

Future<void> startRenderMetric({required String screenName});

Starts measuring render metrics for a specific screen.

stopRenderMetric

Future<void> stopRenderMetric();

Stops measuring render metrics.

Note

This library uses Firebase Performance Monitoring under the hood. Ensure that you have Firebase set up in your Flutter project.

For more information on Firebase Performance Monitoring, refer to the official documentation.