data_result 1.0.1 copy "data_result: ^1.0.1" to clipboard
data_result: ^1.0.1 copied to clipboard

A lightweight, type-safe result type for Dart. Simple alternative to Either with clear success/failure naming.

1.0.1 #

  • Fixed: Shortened package description to meet pub.flutter-io.cn requirements (60-180 characters)
  • Fixed: Code formatting to match Dart formatter standards

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 when method for exhaustive pattern matching
  • βœ… Optional Pattern Matching: Added whenOrNull method for handling only specific cases
  • βœ… Success/Failure Constructors: Simple constructors for creating results
  • βœ… Status Checking: isSuccess getter 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 result
  • DataResult.failure(F failure) - Creates a failed result
  • isSuccess - Returns true if result represents success
  • when({required success, required error}) - Pattern matching requiring both cases
  • whenOrNull({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.

1
likes
160
points
66
downloads

Publisher

verified publishermomaher.dev

Weekly Downloads

A lightweight, type-safe result type for Dart. Simple alternative to Either with clear success/failure naming.

Repository (GitHub)
View/report issues

Topics

#result #error-handling #functional-programming #either #data

Documentation

API reference

License

MIT (license)

More

Packages that depend on data_result