已知问题:存在不继承LifeCycleBaseState的widget,onPause onResume也会走,如果有页面不继承请自行判断当前路由 使用方法

class _Page1State extends LifeCycleBaseState<Page2> {

  @override
  Widget onBuild(BuildContext context) {
    return  Scaffold(
      appBar: AppBar(
        title: const Text("Page2"),
      ),
      body:  Center(
        child: InkWell(
          onTap: (){
            Get.to(Page2(),preventDuplicates: false);
          },
          child: const Text(
              "Page2"
          ),
        ),
      ),
    );
  }

  @override
  void onStart() {
    // TODO: implement onStart
    super.onStart();
  }

  @override
  void onDestory() {
    // TODO: implement onDestory
    super.onDestory();
  }

  @override
  void onPause() {
    // TODO: implement onPause
    super.onPause();
  }

  @override
  void onResume() {
    // TODO: implement onResume
    super.onResume();
  }
}

Libraries

life_state_interface
lifecycle_base_state
page_stack