flutter_performance_optimizer library

A powerful developer tool that automatically detects performance issues in Flutter apps and provides actionable suggestions to fix them.

Quick Start

Wrap your app with the optimizer:

import 'package:flutter_performance_optimizer/flutter_performance_optimizer.dart';

void main() {
  runApp(
    PerformanceOptimizer(
      enabled: true,
      child: MyApp(),
    ),
  );
}

Features

  • Detect excessive widget rebuilds
  • Identify potential memory leaks
  • Find large / expensive widgets
  • Monitor FPS and frame rendering time
  • Detect slow animations and jank
  • Track widget tree depth
  • Highlight unnecessary setState calls
  • Performance overlay dashboard
  • Automatic optimization suggestions
  • Debug & release mode support

Classes

AISuggestionService
Service for generating AI-powered optimization suggestions.
AnimationTracker
Tracks animation performance and detects dropped frames / jank.
DashboardOverlay
A draggable floating overlay that displays the performance dashboard.
FpsGauge
FPS gauge and frame timeline visualization.
FrameTimingData
Data class for frame timing callbacks.
FrameTimingInfo
Detailed frame timing information.
FrameTracker
Tracks frame timing performance using Flutter's SchedulerBinding.
HeatmapOverlay
Overlay that visualizes a heatmap of widget rebuilds.
HeatmapTracker
Tracks global positions of inspected widgets for heatmap visualization.
MemoryChart
Memory usage chart for the dashboard.
MemoryProcessInfo
Internal utility for estimating memory usage via RSS.
MemoryTracker
Tracks memory usage and detects potential memory leaks.
MetricCard
A compact metric card for the dashboard.
MetricsSnapshot
An immutable snapshot of performance metrics at a point in time.
OptimizationSuggestion
Represents an optimization suggestion.
PerformanceConfig
Configuration options for the Performance Optimizer.
PerformanceDashboard
Full performance dashboard widget.
PerformanceFixer
Service that generates automatic code fixes for performance issues.
PerformanceHistoryManager
Manages the historical recording of performance metrics.
PerformanceInspector
Wraps a specific widget to inspect its performance.
PerformanceMetrics
Central hub for all performance metrics.
PerformanceOptimizer
The main performance optimizer widget.
PerformanceScore
Calculates a comprehensive performance score for the app.
PerformanceTestHelper
Helper for CI/CD performance testing.
PerformanceUtils
Utility functions for performance analysis.
PerformanceWarningData
Data class for warning callbacks.
PerformanceWarningManager
Manages performance warnings.
ProfilingTracker
Tracks advanced CPU and GPU metrics via the Dart VM.
RebuildList
Rebuild tracking list for the dashboard.
RebuildTracker
Tracks widget rebuild frequency and detects excessive rebuilds.
ScoreIndicator
A compact score indicator bar.
SetStateTracker
Tracks setState calls and detects unnecessary or excessive usage.
SuggestionEngine
The optimization suggestions engine.
SuggestionsPanel
Suggestions panel for the dashboard.
TimelineChart
Performance history timeline chart.
WidgetDepthInfo
Information about widget tree depth at a specific point.
WidgetDepthTracker
Tracks widget tree depth and complexity.
WidgetSizeTracker
Tracks widget sizes to detect oversized or expensive rendering.

Enums

DashboardPosition
Position for the dashboard overlay.
PerformanceTrend
Trends for performance.
SuggestionCategory
Category of an optimization suggestion.
SuggestionImpact
Estimated impact level.
WarningSeverity
Severity levels for warnings.
WarningType
Types of performance warnings.