### Light Theme Example for Dashboard Source: https://pub.dev/packages/flutter_performance_pulse Apply a predefined light theme to the PerformanceDashboard using DashboardTheme.light(). Ensure the dashboard is enabled in the configuration. ```dart PerformanceDashboard( showFPS: true, showCPU: true, showDisk: true, theme: DashboardTheme.light(), ) ``` -------------------------------- ### Basic Setup for Performance Monitor Source: https://pub.dev/packages/flutter_performance_pulse Initialize the Performance Monitor with default configuration and integrate the PerformanceDashboard into your app's widget tree. Ensure WidgetsFlutterBinding is initialized before calling initialize. ```dart 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(), ); } } ``` -------------------------------- ### Dark Theme Example for Dashboard Source: https://pub.dev/packages/flutter_performance_pulse Apply a predefined dark theme to the PerformanceDashboard using DashboardTheme.dark(). Ensure the dashboard is enabled in the configuration. ```dart PerformanceDashboard( showFPS: true, showCPU: true, showDisk: true, theme: DashboardTheme.dark(), ) ``` -------------------------------- ### Disk Monitoring and Testing Example Source: https://pub.dev/packages/flutter_performance_pulse Enable disk monitoring in the Performance Monitor configuration and display it on the dashboard. Includes a function to test disk operations by writing, reading, and deleting a file. ```dart // 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 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(); } ``` -------------------------------- ### Initialize and Display Performance Monitoring Source: https://pub.dev/packages/flutter_performance_pulse/example Configures the global performance monitor and adds the dashboard overlay to the application's UI. ```dart import 'package:flutter/material.dart'; import 'package:flutter_performance_pulse/flutter_performance_pulse.dart'; import 'package:dio/dio.dart'; import 'package:path_provider/path_provider.dart'; import 'dart:io'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // Initialize the performance monitor await PerformanceMonitor.instance.initialize( config: const MonitorConfig( showMemory: true, showLogs: true, trackStartup: true, interceptNetwork: true, fpsWarningThreshold: 45, enableNetworkMonitoring: true, enableBatteryMonitoring: true, enableDeviceInfo: true, enableDiskMonitoring: true, diskWarningThreshold: 85.0, // Warn at 85% disk usage ), ); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Performance Pulse Demo', 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(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { final Dio _dio = Dio(); bool _isLoading = false; String _diskStatus = ''; // Simulate heavy computation void _performHeavyTask() { setState(() => _isLoading = true); // Create a large list and sort it final list = List.generate(1000000, (i) => 1000000 - i); list.sort(); setState(() => _isLoading = false); } // Make a network request Future _makeNetworkRequest() async { try { await _dio.get('https://jsonplaceholder.typicode.com/posts'); } catch (e) { debugPrint('Network error: $e'); } } // Test disk operations Future _testDiskOperations() async { setState(() => _isLoading = true); try { final appDir = await getApplicationDocumentsDirectory(); final testFile = File('${appDir.path}/test_file.txt'); // Generate a large string final largeString = List.generate(1024 * 1024, (i) => 'A').join(); // 1MB string // Write to file await testFile.writeAsString(largeString); // Read file stats final fileStats = await testFile.stat(); setState(() { _diskStatus = 'File size: ${(fileStats.size / 1024).toStringAsFixed(2)} KB'; }); // Clean up await testFile.delete(); } catch (e) { setState(() { _diskStatus = 'Error: $e'; }); } finally { setState(() => _isLoading = false); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: const Text('Performance Pulse Demo'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ if (_isLoading) const CircularProgressIndicator() else ElevatedButton( onPressed: _performHeavyTask, child: const Text('Perform Heavy Task'), ), const SizedBox(height: 20), ElevatedButton( onPressed: _makeNetworkRequest, child: const Text('Make Network Request'), ), const SizedBox(height: 20), ElevatedButton( onPressed: _testDiskOperations, child: const Text('Test Disk Operations'), ), if (_diskStatus.isNotEmpty) ...[ const SizedBox(height: 10), ``` -------------------------------- ### Add dependency via command line Source: https://pub.dev/packages/flutter_performance_pulse/install Use this command in your terminal to add the package to your Flutter project. ```bash $ flutter pub add flutter_performance_pulse ``` -------------------------------- ### Advanced Performance Monitor Configuration Source: https://pub.dev/packages/flutter_performance_pulse Configure detailed performance monitoring options, set warning thresholds for FPS and memory, and enable various features like network and battery monitoring. Ensure the MonitorConfig is passed to the initialize method. ```dart 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, ), ); ``` -------------------------------- ### Import the package Source: https://pub.dev/packages/flutter_performance_pulse/install Include this import statement in your Dart files to access the package functionality. ```dart import 'package:flutter_performance_pulse/flutter_performance_pulse.dart'; ``` -------------------------------- ### Custom Dashboard Theme Configuration Source: https://pub.dev/packages/flutter_performance_pulse Customize the appearance of the PerformanceDashboard by providing a custom DashboardTheme. This allows control over background color, text color, warning/error colors, and chart colors. ```dart 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), ), ) ``` -------------------------------- ### Add flutter_performance_pulse to pubspec.yaml Source: https://pub.dev/packages/flutter_performance_pulse Add this dependency to your pubspec.yaml file to include the performance monitoring toolkit in your Flutter project. ```yaml dependencies: flutter_performance_pulse: ^1.0.6 ``` -------------------------------- ### Positioning the PerformanceDashboard in MaterialApp Source: https://pub.dev/packages/flutter_performance_pulse Use the builder property of MaterialApp to overlay the PerformanceDashboard on top of the application content using a Stack widget. ```dart 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(), ), ], ); }, ) ``` -------------------------------- ### Add dependency to pubspec.yaml Source: https://pub.dev/packages/flutter_performance_pulse/install Manually add this line to your project's pubspec.yaml file under the dependencies section. ```yaml dependencies: flutter_performance_pulse: ^1.0.6 ``` -------------------------------- ### Display Disk Status in Flutter Source: https://pub.dev/packages/flutter_performance_pulse/example This snippet shows how to display the disk status within a Flutter application's UI. It assumes the disk status is available as a string variable. ```dart Text(_diskStatus) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.