小编cul*_*ljo的帖子

如何在flutter中实现应用程序超时会话

我想在用户未与应用程序交互一段特定时间后注销用户。

我已将整个子小部件包装在GestureDetector().

请建议这是否是执行此操作的最佳优化方法。

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    return new GestureDetector( 
    onTap: () {
      // duration reset's to a specific time 
      startTimeout([int milliseconds]) { return new Timer(duration, handleTimeout); } 
    },
    child: new HomeWidget(),); 
  }

  void handleTimeOut {
    // Log User Out
  }
}
Run Code Online (Sandbox Code Playgroud)

dart flutter

6
推荐指数
1
解决办法
9541
查看次数

标签 统计

dart ×1

flutter ×1