onRestart method

void onRestart(
  1. void handler(
    1. ReloadSucceeded event
    )
)

Fires after every successful hot restart (state lost — main() re-runs). Use this to re-warm caches, re-open connections, etc.

Implementation

void onRestart(void Function(ReloadSucceeded event) handler) {
  on<ReloadSucceeded>((e) {
    if (e.kind == ReloadKind.hotRestart) handler(e);
  });
}