resetHintKit function

void resetHintKit()

Puts the package's process-global state back to how it starts.

HintRegistry outlives any widget tree — that is the point of it, since the overlay it arbitrates is not scoped to a subtree — so without this a test inherits the previous test's open hint, showOnce keys and observers. Symptoms are a hint that mysteriously refuses to appear, or an observer that counts events from two tests at once.

Call it in setUp:

setUp(resetHintKit);

It closes whatever hint holds the floor, drops every registered observer, and replaces HintRegistry.storage with a fresh InMemoryTourStorage.

Implementation

void resetHintKit() {
  HintRegistry.instance
    ..closeAll()
    ..removeAllObservers()
    ..storage = InMemoryTourStorage();
  // Last: assigning storage above counts as setting it, and a fresh process
  // has not. Otherwise every test that runs a tour would be told off for
  // wiring persistence in one place only.
  debugResetStorageWiring();
}