StatefulValueBuilder<T, E extends Object> typedef
Builds UI when StatefulData contains a usable value.
The callback receives:
value— the current usable value.inProgress—truewhen the value is shown while another operation is still running, for exampleLoading(prev)orUpdating(value).error— an optional named parameter. It is provided when the current state isFailure(prev, failure), meaning the old value can still be shown while the latest operation failed.
Important: error is a named callback parameter.
The builder must be written with {error}:
builder: (user, inProgress, {error}) {
return UserView(
user: user,
isRefreshing: inProgress,
errorBanner: error,
);
}
Do not write it as a third positional parameter:
// Wrong:
builder: (user, inProgress, error) {
return UserView(user: user);
}
Implementation
typedef StatefulValueBuilder<T, E extends Object> = Widget Function(
T value,
bool inProgress, {
E? error,
});