【发布时间】:2022-12-31 00:38:26
【问题描述】:
class ExampleWidget extends StatefulWidget {
const ExampleWidget({Key? key}) : super(key: key);
@override
State<ExampleWidget> createState() => _ExampleState();
}
class _ExampleState extends State<ExampleWidget> {
bool showCursor = false;
@override
Widget build(BuildContext context) {
return MouseRegion(
cursor: showCursor ? SystemMouseCursors.basic : SystemMouseCursors.none,
);
}
}
在上面的代码中,在 Windows 上,如果将 showCursor 设置为 false,鼠标光标将被隐藏然后用户移动他的光标.如果 showCursor 的值设置为 false,当用户没有移动他的鼠标时,光标图标不会更新直到用户移动它。
这是由于 Flutter 引擎中的一个错误:https://github.com/flutter/flutter/issues/76622。
我该如何解决这个问题?有没有其他方法可以在 Flutter 中隐藏鼠标光标?
【问题讨论】: