Flutter Performance Pulse 🧠
A real-time, in-app performance monitoring toolkit for Flutter. Designed to help developers detect bottlenecks, debug in production, and ensure a smooth user experience across platforms.
Getting Started 🚀
Add Flutter Pulse to your pubspec.yaml:
dependencies:
flutter_performance_pulse: ^1.0.6
Usage Examples 📱
Basic Setup
import 'package:flutter_performance_pulse/flutter_performance_pulse.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize with default configuration
await PerformanceMonitor.instance.initialize();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My App',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
builder: (context, child) {
return Stack(
children: [
child!,
const Positioned(
right: 16,
bottom: 16,
child: Material(
elevation: 8,
borderRadius: BorderRadius.all(Radius.circular(8)),
child: PerformanceDashboard(
showFPS: true,
showCPU: true,
showDisk: true, // Enable disk monitoring
theme: DashboardTheme(
backgroundColor: Color(0xFF1E1E1E),
textColor: Colors.white,
warningColor: Colors.orange,
errorColor: Colors.red,
chartLineColor: Colors.blue,
chartFillColor: Color(0x40808080),
),
),
),
),
],
);
},
home: const MyHomePage(),
);
}
}
Advanced Configuration
await PerformanceMonitor.instance.initialize(
config: MonitorConfig(
// Performance monitoring options
showMemory: true,
showLogs: true,
trackStartup: true,
interceptNetwork: true,
// Performance thresholds
fpsWarningThreshold: 45,
memoryWarningThreshold: 500 * 1024 * 1024, // 500MB
diskWarningThreshold: 85.0, // Warn at 85% disk usage
// Feature toggles
enableNetworkMonitoring: true,
enableBatteryMonitoring: true,
enableDeviceInfo: true,
enableDiskMonitoring: true,
// Logging options
logLevel: LogLevel.verbose,
exportLogs: true,
),
);
Custom Dashboard Theme
PerformanceDashboard(
showFPS: true,
showCPU: true,
showDisk: true,
theme: DashboardTheme(
backgroundColor: Colors.black87,
textColor: Colors.white,
warningColor: Colors.amber,
errorColor: Colors.redAccent,
chartLineColor: Colors.greenAccent,
chartFillColor: Colors.greenAccent.withOpacity(0.2),
),
)
Light Theme Example
PerformanceDashboard(
showFPS: true,
showCPU: true,
showDisk: true,
theme: DashboardTheme.light(),
)
Dark Theme Example
PerformanceDashboard(
showFPS: true,
showCPU: true,
showDisk: true,
theme: DashboardTheme.dark(),
)
Disk Monitoring Example
// Initialize with disk monitoring
await PerformanceMonitor.instance.initialize(
config: MonitorConfig(
enableDiskMonitoring: true,
diskWarningThreshold: 85.0, // Show warning when disk usage exceeds 85%
),
);
// Add disk monitoring to dashboard
PerformanceDashboard(
showDisk: true,
theme: DashboardTheme.dark(),
)
// Test disk operations
Future<void> testDiskOperations() async {
final appDir = await getApplicationDocumentsDirectory();
final testFile = File('${appDir.path}/test_file.txt');
// Write test data
await testFile.writeAsString('Test data');
// Get file stats
final fileStats = await testFile.stat();
print('File size: ${fileStats.size} bytes');
// Clean up
await testFile.delete();
}
Positioning the Dashboard
MaterialApp(
builder: (context, child) {
return Stack(
children: [
child!,
// Top-right corner
const Positioned(
right: 16,
top: 16,
child: PerformanceDashboard(),
),
// Or bottom-left corner
const Positioned(
left: 16,
bottom: 16,
child: PerformanceDashboard(),
),
// Or any other position
const Positioned(
right: 16,
bottom: 16,
child: PerformanceDashboard(),
),
],
);
},
)
Features ✨
-
📊 Real-time FPS & Memory Usage Tracker
- Live FPS monitoring with tooltips
- Heap memory usage tracking
- Visual performance graphs
- Optimized chart rendering
- Gesture-controlled zoom
- Export capabilities
-
🚀 CPU & GPU Monitoring
- CPU usage per core
- GPU rendering statistics
- Frame build time analysis
- Reduced monitoring overhead
- Custom event tracking
- Performance alerts
-
💾 Disk Usage Monitor
- Total storage space tracking
- Free space monitoring
- App storage usage analysis
- Visual disk usage graphs
- Configurable warning thresholds
- Automatic 5-second refresh
- Enhanced error recovery
- Storage trend analysis
-
🛠️ App Startup Time Analyzer
- Cold start measurements
- Warm start tracking
- First frame render timing
- Performance optimization tips
- Startup bottleneck detection
- Custom event markers
-
🔍 Network Request Logger
- API request monitoring
- Response time tracking
- Error logging
- Detailed metrics analysis
- Request filtering
- Export capabilities
-
📦 Battery & Device Info
- Battery status monitoring
- Device specifications
- System resource usage
- Platform-specific features
- Temperature monitoring
- Power usage analytics
Platform Support 🌍
Platform | Support |
---|---|
Android | ✅ |
iOS | ✅ |
Web | ✅ |
macOS | ⚠️ Limited |
Windows | ⚠️ Limited |
Linux | ⚠️ Limited |
Contributing 🤝
Contributions are welcome! Please read our contributing guidelines to get started.
License 📄
This project is licensed under the MIT License - see the LICENSE file for details.