Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振:有没有办法在web应用程序中获取退出事件?_Flutter_Flutter Web - Fatal编程技术网

Flutter 颤振:有没有办法在web应用程序中获取退出事件?

Flutter 颤振:有没有办法在web应用程序中获取退出事件?,flutter,flutter-web,Flutter,Flutter Web,我想在用户关闭或重新加载网页(web应用程序)时调用API 收听活动 html.window.onBeforeUnload.listen( (event) async { Map<String, dynamic> _exit = await callApi(CloseRoomAPI); print(_exit); }, ); html.window.onBeforeUnload.listen( (事件)异步{ Map _exit=wait callApi(C

我想在用户关闭或重新加载网页(web应用程序)时调用API

收听活动

html.window.onBeforeUnload.listen(
  (event) async {
    Map<String, dynamic> _exit = await callApi(CloseRoomAPI);
    print(_exit);
  },
);
html.window.onBeforeUnload.listen(
(事件)异步{
Map _exit=wait callApi(CloseRoomAPI);
打印(_退出);
},
);
调用API函数

    Future<Map<String, dynamic>> callApi(String _url) async {
  final client = new http.Client();

  final connection = await client.get(_url);

  if (connection.statusCode == 200) {
    return jsonDecode(connection.body.toString());
  } else {
    return null;
  }
}
Future callApi(String\u url)异步{
final client=new http.client();
最终连接=等待client.get(_url);
如果(connection.statusCode==200){
返回jsonDecode(connection.body.toString());
}否则{
返回null;
}
}
-YMMV。可能会用这个词来找到特定于颤振的东西YMMV。可能会使用该术语来查找特定于颤振的内容。