ScrizerBlocState<T> class
A generic BLoC state class that encapsulates data, its state, and any related failure.
ScrizerBlocState is useful for managing and representing the state of asynchronous operations in Flutter using the BLoC pattern.
It provides helper getters to simplify state checking, such as isInitial, isLoading, isSuccess, and hasError.
Constructors
- ScrizerBlocState.new({T? data, ScrizerDataState state = ScrizerDataState.initial, Failure failure = const EmptyFailure()})
-
Creates a ScrizerBlocState with optional
data
, astate
defaulting to ScrizerDataState.initial, and an optionalfailure
(defaults to EmptyFailure).const - ScrizerBlocState.error(Failure failure)
-
Creates an error state with a
failure
.factory - ScrizerBlocState.initial({T? data})
-
Creates an initial state with optional
data
.factory - ScrizerBlocState.loading()
-
Creates a loading state.
factory
- ScrizerBlocState.success(T data)
-
Creates a success state with
data
.factory - ScrizerBlocState.withDefault(T defaultData)
-
Factory constructor to create a state with default data.
factory
Properties
- data → T?
-
The data associated with this state, if any.
final
- failure → Failure
-
The failure information, if the state is in error.
final
- hasData → bool
-
Checks if there is valid data and the state is ScrizerDataState.success.
no setter
- hasError → bool
-
Indicates whether the state is ScrizerDataState.error.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitial → bool
-
Indicates whether the state is ScrizerDataState.initial.
no setter
- isLoading → bool
-
Indicates whether the state is ScrizerDataState.loading.
no setter
- isSuccess → bool
-
Indicates whether the state is ScrizerDataState.success.
no setter
-
props
→ List<
Object?> -
The list of properties that will be used to determine whether
two instances are equal.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → ScrizerDataState
-
The current state of the data (initial, loading, success, error).
final
- stringify → bool?
-
If set to
true
, thetoString
method will be overridden to output this instance'sprops
.no setterinherited - value → T
-
Returns the current data value. Should only be accessed when hasData is true.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited