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 fallbackssafeSetState()- Prevent setState after dispose errorssafeAsync()- Safe async operations with mounted checkssafeBuild()- Build widgets with automatic fallback UIarmorImage()- Load images with error handlingarmorNetworkRequest()- Network calls with retry logicarmorTimer()- Managed timers with auto cleanuparmorStreamListen()- 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