updateOnlyPhase method
Runs the provided asynchronous function and only updates the phase.
The phase is updated to AsyncWaiting when the callback starts, and to AsyncComplete or AsyncError according to success or failure when the callback ends.
This is the same as update except that this method does not update
value.data
.
This method is useful when it is necessary to update the phase during execution but the callback result should not affect the data.
e.g. Indicating the waiting status on the UI or notifying the phase change to other parts of the code, with the existing data being kept unchanged.
Implementation
Future<AsyncPhase<T>> updateOnlyPhase(Future<void> Function() func) async {
final phase = await update(() async {
await func();
return data;
});
value = phase;
return value;
}