flutter_app_vitals

Real-time Flutter performance monitoring overlay — startup time, FPS, memory, CPU, network latency, and widget rebuild tracking displayed directly inside your running application.

Features

  • App startup time — measures time from start() to first frame rendered
  • FPS & frame timing — rolling average FPS, slow frame count, jank detection
  • Memory usage — resident set size via dart:io, or native values via platform channel
  • CPU usage — via platform channel (Android ActivityManager / iOS host_processor_info)
  • Network tracking — request count, failed requests, average latency, generic interceptor
  • Widget rebuild counting — per-widget or global via RebuildCounter wrapper
  • Floating overlay dashboard — draggable, minimisable, semi-transparent dark panel

Getting Started

Add the package to your pubspec.yaml:

dependencies:
  flutter_app_vitals:
    path: ../flutter_app_vitals # or a pub version once published

Usage

1. Start monitoring

import 'package:flutter_app_vitals/flutter_app_vitals.dart';

void main() {
  final vitals = VitalsManager();
  vitals.start();
  runApp(const MyApp());
}

2. Stop the startup timer after the first frame

WidgetsBinding.instance.addPostFrameCallback((_) {
  VitalsManager.instance.stopStartup();
});

3. Show the overlay

Stack(
  children: [
    MyApp(),
    VitalsOverlay(),
  ],
)

4. Track network requests

final tracker = VitalsManager.instance.networkTracker;

// Manual tracking
final record = tracker.trackRequest('https://api.example.com/data');
final response = await http.get(Uri.parse('https://api.example.com/data'));
tracker.completeRequest(record, statusCode: response.statusCode);

// Or use the convenience wrapper
final response = await tracker.trackHttpCall(
  'https://api.example.com/data',
  () => http.get(Uri.parse('https://api.example.com/data')),
  extractStatusCode: (r) => r.statusCode,
);

5. Track widget rebuilds

RebuildCounter(
  tracker: VitalsManager.instance.rebuildTracker,
  label: 'ProductList',
  child: ProductList(),
)

6. Read the report programmatically

final report = VitalsManager.instance.report;
print(report);
// ## Performance Report
// Startup Time: 1.2 seconds
// Average FPS: 58
// Slow Frames: 6
// Memory Usage: 120 MB
// CPU Usage: 18%
// API Average Latency: 320 ms
// Failed Requests: 1
// Widget Rebuilds: 45

Platform Channel Setup (optional)

CPU and detailed memory metrics require native handlers on the following channels:

Channel Method Returns
flutter_app_vitals/cpu getCpuUsage double (0–100 %)
flutter_app_vitals/memory getMemoryUsage double (MB)

When no native handler is registered, CPU defaults to 0 % and memory falls back to ProcessInfo.currentRss.

Architecture

lib/
  flutter_app_vitals.dart        # library exports
  core/
    vitals_manager.dart          # central controller
    performance_report.dart      # data model
  trackers/
    startup_tracker.dart
    fps_tracker.dart
    rebuild_tracker.dart
    network_tracker.dart
    memory_tracker.dart
    cpu_tracker.dart
  overlay/
    vitals_overlay.dart          # floating dashboard widget

License

MIT License. See LICENSE for details.

Author

Developed by Abhishek Sharma

Contributions and issues are welcome — please open a ticket on GitHub.