UiResult<T> class
Result wrapper for UiPort operations.
All UiPort methods return this type instead of throwing exceptions.
success is false when error is present. Warnings may be present
even when success is true.
Constructors
-
UiResult({required bool success, T? data, UiError? error, List<
UiError> ? warnings}) -
const
- UiResult.fail(UiError error)
-
Create a failed result.
const
-
UiResult.fromJson(Map<
String, dynamic> json, T dataFromJson(Map<String, dynamic> )) -
Create from JSON with a converter for the generic data field.
factory
- UiResult.ok(T data)
-
Create a successful result.
const
-
UiResult.okWithWarnings(T data, List<
UiError> warnings) -
Create a successful result with warnings.
const
Properties
- data → T?
-
Result data on success.
final
- error → UiError?
-
Error details on failure.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- success → bool
-
Whether the operation succeeded.
final
-
warnings
→ List<
UiError> ? -
Optional warnings from the operation.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
[Map< String, dynamic> dataToJson(T)?]) → Map<String, dynamic> - Serialize to JSON with a converter for the generic data field.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited