complete method Null safety

void complete(
  1. [T callback(
    1. T
    )?]
)

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([T Function(T)? callback]) {
  _completed = true;
  final state = callback?.call(_notifier.value) ?? _notifier.value;
  if (state == _notifier.value) {
    // ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
    _notifier.notifyListeners();
  }
  _notifier.value = state;
}