unregister method

void unregister(
  1. BuildContext context, {
  2. bool async = false,
})

移除广播系统中,注册到 context 环境内的所有接收者。 例如,在页面关闭时,开发者可以通过 unregister 一次性移除注册到该环境内的所有接收者。 当然,前提时在接收者通过 register 注册的时候,传入 context,将接收者注册到该环境中。 context - 环境。

Remove all receivers registered in the context environment from the broadcast system. For example, when the page is closed, the developer can use unregister to remove all recipients registered in the environment at once. Of course, the prerequisite is that when the receiver registers through register, pass in context to register the receiver to the environment. context - context.

Implementation

void unregister(BuildContext context, {bool async = false}) {
  if (async) {
    _unregisterAsync(context);
  } else {
    _unregister(context);
  }
}