- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 flutter (Windows) 开发桌面应用程序,如果用户尝试使用关闭按钮关闭窗口,我需要设置一个 AlertDialog。
如果有人有想法甚至解决方案,我会采纳 :D
我在下面附上了一张引用图片。
最佳答案
window_manager 现在支持这个。
import 'package:flutter/cupertino.dart';
import 'package:window_manager/window_manager.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> with WindowListener {
@override
void initState() {
windowManager.addListener(this);
_init();
super.initState();
}
@override
void dispose() {
windowManager.removeListener(this);
super.dispose();
}
void _init() async {
// Add this line to override the default close handler
await windowManager.setPreventClose(true);
setState(() {});
}
@override
Widget build(BuildContext context) {
// ...
}
@override
void onWindowClose() async {
bool _isPreventClose = await windowManager.isPreventClose();
if (_isPreventClose) {
showDialog(
context: context,
builder: (_) {
return AlertDialog(
title: Text('Are you sure you want to close this window?'),
actions: [
TextButton(
child: Text('No'),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Yes'),
onPressed: () {
Navigator.of(context).pop();
await windowManager.destroy();
},
),
],
);
},
);
}
}
}
https://github.com/leanflutter/window_manager#confirm-before-closing
关于 flutter 桌面 : How to catch closure button?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63115627/
我刚刚开始使用 Google Closure 做一些工作,我想将选择字段的创建移动到它自己的模板中,并使用类似以下内容调用该模板: {call templates.utils.select} {p
我有一些代码,简化后看起来像: fn foo() -> Vec { unsafe { unsafe_iterator().map(|n| wrap_element(n)).co
我正在从脚本内部调用Closure Compiler(closurecompiler.jar)。该脚本还生成Closure Compiler需要编译的一些javascript。有没有办法将此JavaS
以下示例代码生成有关高级优化的编译器警告:“JSC_UNSAFE_NAMESPACE:为命名空间 NS 创建的别名不完整”。如果我删除@enum 注释,它不会发出警告。 var NS = {}; /*
看代码: let add_one = |&: x| { 1 + x }; 我知道x是闭包参数,但是闭包中的&:是什么意思? 最佳答案 这是 Rust 的一个文档不足的部分(并且过时,请参阅评论)。我知
PHP manual for anonymous functions (即闭包)指出: Anonymous functions are currently implemented using the
我从脚本内部调用 Closure Compiler (closurecompiler.jar)。该脚本还生成了一些 Closure Compiler 需要编译的 javascript。有没有办法将这个
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 7年前关闭。 Improve t
当鼠标在文档正文中移动时,我试图调用一个函数。但是,下面的事件处理程序不起作用。 goog.events.listen(document, 'onmousemove', function(e)
我试过了 java -jar compiler.jar --js jj.js --js_output_file jj.js 输出文件大小为 0。 如果我不想从 .min.js 重命名为 .js,我该怎
Google Closure UI库如何与Google DART一起使用? 最佳答案 Dart没有使用JavaScript库的功能。这是设计使然,因为Dart旨在同时针对Dart VM和转换为JS的D
是否可以使用 Google Closure 编译器在两个文件中定义一个类?例如,如果我自动生成一个类并希望为用户输入的代码保留另一个类: 在 MyClass.AutoGenerated.js 中 go
当我在 http://closure-compiler.appspot.com 处的闭包编译器中测试以下代码时: // ==ClosureCompiler== // @output_file_name
是否可以使用 Google Closure 编译器在两个文件中定义一个类?例如,如果我自动生成一个类并希望为用户输入的代码保留另一个类: 在 MyClass.AutoGenerated.js 中 go
当我运行闭包编译器时,会收到一堆这样的警告: [exec] jquery/3.2.1/dist/jquery.js:733: WARNING - Suspicious code. The resul
假设您正在一个具有多个外部库依赖项的 javascript 项目中工作,并且想要在 ADVANCED_OPTIMIZATIONS 模式下使用 Google Closure Compiler 编译您的源
我正在为 PIXI.js 库准备 externs。我收到以下警告: js/Test.js:188: WARNING - Property position never defined on PIXI.
我最近使用 Google 的 Closure 编译器创建了一个 JavaScript 库:https://github.com/bvaughn/task-runner 我打算让这个库供那些也需要完整闭
我正在尝试自学闭包模板。我做了一个简单的文件 simple.soy: {namespace examples.simple} /** * says hello to the world * @pa
我正在将一个项目从 jQuery 迁移到 Closure。我有一些我想编译的只迁移了一半的代码。未编译的源工作正常。我想知道使用 SIMPLE_OPTIMIZATIONS 编译它的编译命令。 原始基于
我是一名优秀的程序员,十分优秀!