Flutter GetX 中使用 mounted

1 min read

mount只能在Statefull Widget 中调用,因此不能在Controller中使用它。如果您使用的是命名路由,我想您可以获取页面的当前名称并执行某些操作。

if(Get.routing.current == "/home"){
   doSomething();
}