搜索插件、代码仓与 APP 分类

插件详情v0.0.4

flutter_custom_cursor

直接从内存缓冲区创建/设置自定义鼠标光标。

macOSWindowsLinux
近 30 天下载
5.4万
喜欢数
19
Pub 分数
140

安装插件

flutter pub add flutter_custom_cursor

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,允许开发者在桌面平台上使用内存缓冲区设置自定义鼠标光标。它通过直接从内存加载光标数据,实现对光标外观的精确控制,非常适合需要独特或动态光标设计的应用程序。该包专门针对 Windows、Linux 和 macOS 设计,可与 Flutter 的桌面目标无缝集成。它支持高级光标自定义,无需依赖外部文件,从而在 UI 设计中提升性能和灵活性。

适合场景

  • 游戏中的自定义光标
  • 交互式 UI 元素
  • 桌面应用程序品牌化
  • 动态光标更改
  • 高性能光标渲染
  • 可访问性功能

主要特点

  • 直接内存缓冲区输入
  • 跨平台桌面支持
  • 无外部文件依赖
  • 高性能
  • 与 Flutter 的轻松集成
  • 支持动画光标

适合对象

  • 桌面应用程序开发者
  • 游戏开发者
  • UI/UX 设计师
  • 需要唯一光标行为的应用程序
  • 对性能敏感的项目

使用建议

  • 仅限桌面平台
  • 需要平台特定的实现知识
  • 游标缓冲区的内存管理
  • 不适合用于移动应用
  • 光标大小和格式约束
  • 与某些操作系统版本可能存在兼容性问题

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flutter_custom_cursor

This plugin allows to create/set a custom mouse cursor directly from a memory buffer.

Big thanks to imiskolee to create the base of this plugin.

Platforms

  • [x] macOS
  • [x] Windows
  • [x] Linux

Note: Currently, the api required by this plugin on Windows is included in flutter master branch. It means that u need to use this plugin with flutter master branch on Windows platform. See flutter engine PR#36143 for details.

Update: the latest Flutter 3.7.0 does not contain PR above, which merges to flutter-3.7.0-candidate.2, while Flutter stable 3.7.0 is using flutter-3.7.0-candidate.1. This limitation will be lifted maybe in the next Flutter stable release.

Get prepared

Register your custom cursor before

// register this cursor
cursorName = await CursorManager.instance.registerCursor(CursorData()
  ..name = "test"
  ..buffer =
      Platform.isWindows ? memoryCursorDataRawBGRA : memoryCursorDataRawPNG
  ..height = img.height
  ..width = img.width
  ..hotX = 0
  ..hotY = 0);

Note that a String cacheName will be returned by the function registerCursor, which can be used to set this cursor to system or delete this cursor.

CursorData.buffer is a Uint8List which contains the cursor data. Be aware that on Windows, buffer is formatted by rawBGRA, other OS(s) are rawPNG.

see the example project for details.

Set the custom cursor

We have implemented the FlutterCustomMemoryImageCursor class, which is a subclass of MouseCursor. This class will automatically set the memory cursor for you. Keep it simple.

MouseRegion(
  cursor: FlutterCustomMemoryImageCursor(key: cursorName),
  child: Row(
    children: [
      Text("Memory image here", style: style),
    ],
  ),
),

Delete the cursor

You can delete a cursor with the cursorName.

await CursorManager.instance.deleteCursor("cursorName");

所属分类

源码仓库

使用此插件的项目