complete method

void complete([
  1. FlowCallback<T>? callback
])

complete can be called to complete the current flow. complete takes a closure which exposes the current flow state and is responsible for returning the new flow state.

When complete is called, the flow is popped with the new flow state.

Implementation

void complete([FlowCallback<T>? callback]) {
  _completed = true;
  final nextState = callback?.call(_state) ?? _state;
  _state = nextState;
  notifyListeners();
}