app_monitor 1.0.3 copy "app_monitor: ^1.0.3" to clipboard
app_monitor: ^1.0.3 copied to clipboard

App monitoring lib for logging and error handling.

AppMonitor - Flutter Error Monitoring & Logging Library #

A comprehensive error monitoring and logging solution for Flutter applications that helps developers track, record, and manage errors efficiently with local SQLite storage and customizable error handling.

Features ✨ #

  • πŸ“ Automatic Error Capturing - Catches all Flutter framework errors and Dart runtime errors
  • πŸ’Ύ Persistent Storage - SQLite database for reliable error log persistence
  • πŸ” Detailed Error Reports - Captures error messages, stack traces, and timestamps
  • ⚑ Performance Optimized - Lightweight and non-blocking error recording
  • πŸ›‘οΈ Crash Prevention - Optional prevention of app crashes from uncaught exceptions
  • οΏ½ Custom Error Handling - Add your own error handling logic
  • πŸ”„ Log Management - View, filter, and delete error logs
  • 🧩 Easy Integration - Simple setup with powerful results
  • 🌐 Navigator Integration - Built-in global navigator key for error dialogs

Installation πŸ’» #

Add the dependency to your pubspec.yaml:

dependencies:
  app_monitor: ^1.0.3

Usage πŸš€ #

import 'package:app_monitor/app_monitor.dart';

void main() async {
  // Ensure Flutter binding is initialized
  WidgetsFlutterBinding.ensureInitialized();

  final scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
  final appMonitor = AppMonitor();

  // Initialize AppMonitor
  await appMonitor.initialize(
    appName: 'MyApp',
    onError: (error, stack) {
      debugPrint('Stack: $stack');

      scaffoldMessengerKey.currentState?.showSnackBar(
        SnackBar(content: Text(error)),
      );
    },
  );

  // Run the app
  runApp(
    MyApp(scaffoldMessengerKey: scaffoldMessengerKey, appMonitor: appMonitor),
  );
}

Methods #

/// Retrieves all error logs from database, sorted by most recent
Future<List<Map<String, dynamic>>> getAllLogs() async {
  return await _db.query('logs', orderBy: 'timestamp DESC');
}

/// Clears all error logs from the database
///
/// Returns:
///   Number of records deleted
Future<int> deleteAllLogs() async {
  return await _db.delete('logs');
}

/// Deletes a specific error log by its ID
///
/// Parameters:
///   - id: The ID of the log record to delete
///
/// Returns:
///   Number of records deleted (0 or 1)
Future<int> deleteLog(int id) async {
  return await _db.delete('logs', where: 'id = ?', whereArgs: [id]);
}

License πŸ“œ #

MIT License

Copyright (c) 2025 Ferid Cafer

1
likes
160
points
27
downloads

Publisher

unverified uploader

Weekly Downloads

App monitoring lib for logging and error handling.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, path, sqflite

More

Packages that depend on app_monitor