onInit method

  1. @override
void onInit()
override

Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.

Implementation

@override
void onInit() {
  super.onInit();
  refreshUiSubscription = eventListen<RefreshUiEvent>((event) {
    // 延时刷新UI
    delayed(300, () {
      updateUi();
    });
  });
  if (listenLifecycleEvent) {
    lifecycleSubscription = eventListen<LifecycleEvent>((event) {
      switch (event.state) {
        case AppLifecycleState.resumed:
          onResumed();
          break;
        case AppLifecycleState.inactive:
          onInactive();
          break;
        case AppLifecycleState.detached:
          onDetached();
          break;
        case AppLifecycleState.paused:
          onPaused();
          break;
        case AppLifecycleState.hidden:
          onHidden();
          break;
      }
    });
  }
}