data_result 1.0.0
data_result: ^1.0.0 copied to clipboard
A lightweight, type-safe result type for Dart that elegantly handles success and failure states without exceptions. Perfect for clean error handling in your Dart and Flutter applications.
1.0.0 #
Initial Release π
Features #
- β
Type-safe Result Type: Introduced
DataResult<S, F>sealed class for handling success and failure states - β
Pattern Matching: Added
whenmethod for exhaustive pattern matching - β
Optional Pattern Matching: Added
whenOrNullmethod for handling only specific cases - β Success/Failure Constructors: Simple constructors for creating results
- β
Status Checking:
isSuccessgetter for quick status checks - β Zero Dependencies: Pure Dart implementation with no external dependencies
- β Comprehensive Documentation: Full dartdoc comments for all APIs
- β Rich Examples: Multiple real-world usage examples included
- β Complete Test Coverage: Extensive unit tests covering all functionality
API #
DataResult.success(S data)- Creates a successful resultDataResult.failure(F failure)- Creates a failed resultisSuccess- Returns true if result represents successwhen({required success, required error})- Pattern matching requiring both caseswhenOrNull({success, failure})- Optional pattern matching
Documentation #
- Comprehensive README with multiple examples
- Full API reference documentation
- Real-world usage scenarios
- Comparison with traditional error handling
- Best practices guide
Examples #
- Basic success/failure handling
- API call simulation
- Form validation
- Database operations
- File operations
- Pattern matching demonstrations
This is the first stable release of data_result. The package provides a robust, type-safe way to handle operations that can succeed or fail, inspired by Result types from functional programming languages.