exa_performance_flutter 0.0.1 copy "exa_performance_flutter: ^0.0.1" to clipboard
exa_performance_flutter: ^0.0.1 copied to clipboard

unlisted

A Flutter package project about performance.

example/lib/main.dart

import 'package:exa_performance_flutter/app/features/exa_performance.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  Firebase.initializeApp();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Exa Performance Example',
      home: ExamplePage(),
    );
  }
}

class ExamplePage extends StatefulWidget {
  const ExamplePage({super.key});

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  final ExaPerformance _exaPerformance = ExaPerformance();

  @override
  void initState() {
    _exaPerformance.startRenderMetric(screenName: 'ExamplePage');
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    _exaPerformance.stopRenderMetric();
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text("Exa Performance Example"),
      ),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text(
              'Exa Performance Example',
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 16),
            const Text(
              'This is an example of how to use Exa Performance',
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: 16,
              ),
            ),
            const SizedBox(height: 56),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                ElevatedButton(
                  onPressed: _testNetwork,
                  child: const Text('TestNetwork'),
                ),
                const SizedBox(width: 16),
                ElevatedButton(
                  onPressed: _testTrace,
                  child: const Text('TestTrace'),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }

  void _testNetwork() {
    _exaPerformance.testNetwork(
      'https://www.facebook.com',
      attributes: {
        'test': 'test',
      },
    );
  }

  void _testTrace() {
    _exaPerformance.testTrace(
      'testTrace',
      function: () async {
        await Future.delayed(const Duration(seconds: 2));
      },
    );
  }
}
0
likes
140
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package project about performance.

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

firebase_performance, flutter, get_it, http

More

Packages that depend on exa_performance_flutter