Search packages, repositories and app categories

Package detailsv0.0.4

flutter_custom_cursor

Create/Set a custom mouse cursor directly from a memory buffer.

macOSWindowsLinux
30-day downloads
54.2K
Likes
19
Pub points
140

Install package

flutter pub add flutter_custom_cursor

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter package that enables developers to set custom mouse cursors on desktop platforms using a memory buffer. It allows precise control over cursor appearance by loading cursor data directly from memory, ideal for applications requiring unique or dynamic cursor designs. The package is specifically tailored for Windows, Linux, and macOS, offering seamless integration with Flutter's desktop targets. It supports advanced cursor customization without relying on external files, enhancing performance and flexibility in UI design.

Use cases

  • Custom cursor in games
  • Interactive UI elements
  • Desktop application branding
  • Dynamic cursor changes
  • High-performance cursor rendering
  • Accessibility features

Key features

  • Direct memory buffer input
  • Cross-platform desktop support
  • No external file dependency
  • High performance
  • Easy integration with Flutter
  • Supports animated cursors

Suitable for

  • Desktop app developers
  • Game developers
  • UI/UX designers
  • Applications needing unique cursor behavior
  • Performance-sensitive projects

Considerations

  • Limited to desktop platforms
  • Requires platform-specific implementation knowledge
  • Memory management for cursor buffers
  • Not suitable for mobile apps
  • Cursor size and format constraints
  • Potential compatibility issues with certain OS versions

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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");

Categories

Source repository

Projects using this package