unmount method

  1. @override
void unmount()
override

Disposes the states, the last first, all of them also when one throws; the first error is thrown once the element is unmounted.

Implementation

@override
void unmount() {
  final states = List.of(_hooks.reversed);
  _hooks.clear();
  Object? error;
  StackTrace? stack;
  for (final state in states) {
    try {
      state?._unmount();
    } on Object catch (e, s) {
      error ??= e;
      stack ??= s;
    }
  }
  super.unmount();
  if (error != null) {
    Error.throwWithStackTrace(error, stack!);
  }
}