UPDATE (2021/05/11):

Flatter现在本机已经实现了悬停事件小部件.

对于RaisedButton等小部件和hoverColor或hoverElevation等属性,有一个MouseCursor.

https://api.flutter.dev/flutter/rendering/MouseCursor-class.html

你也可以在其他任何地方使用墨水池,就像接受的答案中所说的那样.


Original Question:

How can the cursor appearance be changed within Flutter? I know that with the 100 Widget we can listen for Mouse-Events, but I haven't found any information regarding hovering events for flutter web. Has someone found a soulution yet?

推荐答案

我很难找到关于现在内置支持的文档.这是对我有帮助的:https://github.com/flutter/flutter/issues/58260

这为我做到了这一点,而没有更改index.html等.

MouseRegion(
  cursor: SystemMouseCursors.click,
    child: GestureDetector(
      child: Icon(
        Icons.add_comment,
        size: 20,
        ),
      onTap: () {},
    ),
  ),

另请参阅官方文档:https://api.flutter.dev/flutter/rendering/MouseCursor-class.html

Widget build(BuildContext context) {
  return Center(
    child: MouseRegion(
      cursor: SystemMouseCursors.text,
      child: Container(
        width: 200,
        height: 100,
        decoration: BoxDecoration(
          color: Colors.blue,
          border: Border.all(color: Colors.yellow),
        ),
      ),
    ),
  );
}

这里还有https://api.flutter.dev/flutter/material/MaterialStateMouseCursor-class.html个来自官方文档的精彩示例,"……定义了一个鼠标光标,当它的小部件被禁用时,该鼠标光标将解析为SystemMouseCursors.forted."

Flutter相关问答推荐

为什么我需要等待重新访问Firestore数据库,即使它已经做了之前?

从Flutter应用程序解释蓝牙BLE数据:了解Sylvania压力值

TextFormfield无法与自动路由一起正常工作

无法构建AndroidBundle 包或iOS等

Flutter为什么不;没有ListView.iterable()构造函数?

使用 forLoops 在 Dart 中进行单元测试会返回 stackoverflow

Flutter:使用不包含导航器的上下文请求导航器操作

Flutter:我应该使用哪种应用内购买服务?

允许文本小部件在容器之间溢出

Flutter 中的 Provider 不会在第一次构建 App 时返回

是否可以在 flutter 应用程序中使用 jetpack compose?

在 Flutter 中显示有关提供者通知的对话框

如何更改 DropDownMenu 的显示方向?

Agora VideoCall 不显示远程视频网格

如何将 List 转换为 String []?

通过点击缩略图加载全屏图像

使用 onPressed 切换到另一个屏幕无法正常工作

Flutter - 异步文件读取异常处理

Flutter Widget 测试:无法使用 find.byWidget() 找到小部件

如何从用户 Flutter 导航抽屉中隐藏管理菜单