armor library

Armor - Bulletproof protection for Flutter apps

Automatically handles crashes, errors, and failures with graceful recovery.

Quick Start

Add the ArmorMixin to any StatefulWidget:

import 'package:armor/armor.dart';

class MyWidget extends StatefulWidget with ArmorMixin {
  // Your widget is now protected against all common Flutter errors
}

Initialize error interception in your main function:

void main() {
  ArmorInterceptor.initialize(); // Enable global error protection
  runApp(MyApp());
}

Features

  • ๐Ÿšซ Prevents crashes and red error screens
  • ๐Ÿ”„ Automatic error recovery with graceful fallbacks
  • ๐Ÿ“ Handles render overflow (yellow/black stripes)
  • ๐ŸŒ Network error handling with retry logic
  • ๐Ÿ–ผ๏ธ Safe image loading with automatic fallbacks
  • โšก Performance monitoring
  • ๐Ÿงน Automatic resource cleanup

Core Methods

  • safeExecute() - Execute any code safely with fallbacks
  • safeSetState() - Prevent setState after dispose errors
  • safeAsync() - Safe async operations with mounted checks
  • safeBuild() - Build widgets with automatic fallback UI
  • armorImage() - Load images with error handling
  • armorNetworkRequest() - Network calls with retry logic
  • armorTimer() - Managed timers with auto cleanup
  • armorStreamListen() - Protected stream subscriptions

Classes

ArmorInterceptor
Central error interceptor for Armor protection system
ArmorRegistry
Registry for tracking Armor healing activities
InterceptedError
Represents an error that was intercepted by the Armor system

Mixins

ArmorMixin<T extends StatefulWidget>
Armor mixin that provides bulletproof protection for Flutter widgets