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

A global error handler package for Flutter applications. `runZonedGuarded`, `Async error handling`, 'Custom error handling', `Pre-app initialization`

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_error_handler/flutter_error_handler.dart';

void main() async {
  // Initialize global error handling with the error handler package
  await FlutterErrorHandler.init(
    app: const MyApp(), // Pass your app widget here
    preAppInitialization: () async {
      // Do any pre-initialization logic here (e.g., loading preferences)
    },
    onErrorHandler: (Object error, StackTrace stackTrace) {
      // Custom logging or error handling logic
      print("Custom Error Handler:");
      print("Error: $error");
      print("StackTrace: $stackTrace");
    },
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Error Handler Example')),
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              throw Exception('This is a test error!');
            },
            child: const Text('Throw Error'),
          ),
        ),
      ),
    );
  }
}
3
likes
160
pub points
49%
popularity

Publisher

verified publisheresolutionsprovider.com

A global error handler package for Flutter applications. `runZonedGuarded`, `Async error handling`, 'Custom error handling', `Pre-app initialization`

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface, web

More

Packages that depend on flutter_error_handler