Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FullLifeCycleMixin的回调方法没有执行,找不到原因! #3032

Closed
wangxp423 opened this issue Feb 4, 2024 · 1 comment
Closed
Assignees

Comments

@wangxp423
Copy link

example:

class MainAppPage extends StatelessWidget {
  MainAppPage({super.key});
  var mainProvider = Get.put(MainAppProvider());

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      child: Text("这是app主页"),
    );
  }
}
class MainAppProvider extends FullLifeCycleController with FullLifeCycleMixin {
  @override
  void onDetached() {
    // TODO: implement onDetached
    print("testxp.mixin.onDetached");
  }

  @override
  void onHidden() {
    // TODO: implement onHidden
    print("testxp.mixin.onHidden");
  }

  @override
  void onInactive() {
    // TODO: implement onInactive
    print("testxp.mixin.onInactive");
  }

  @override
  void onPaused() {
    // TODO: implement onPaused
    print("testxp.mixin.onPaused");
  }

  @override
  void onResumed() {
    // TODO: implement onResumed
    print("testxp.mixin.onResumed");
  }

}

To Reproduce
上面是我的代码,我这么用这个代码在一个新建的项目里面print里面的日志可以打印,
但是如果吧上面的代码放在我的项目里面,print不会执行,我不知道是什么原因导致的。
想问一下,什么可以影响到WidgetsFlutterBinding的回调。

@wangxp423
Copy link
Author

我找到问题的原因了。是因为我用了SystemChannels.lifecycle这个方法来监听页面生命周期,导致getx自带的FullLifecycler失效了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants