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

rough_notation 封面
插件详情v0.0.3

rough_notation

使用 Flutter 的 CustomPainter 在控件上创建动画的手绘风格注释。灵感来自 Rough Notation JS 库。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
68
喜欢数
5
Pub 分数
160

安装插件

flutter pub add rough_notation

插件介绍

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

Rough Notation 是一个 Flutter 包,允许开发者使用 CustomPainter 向小部件添加动画的手绘风格注释。受 Rough Notation JavaScript 库的启发,它为文本和 UI 元素带来了一种草图般的、富有表现力的外观。非常适合用动态、风格化的线条和形状突出显示内容的关键部分。支持 Android、iOS、Web、macOS、Windows 和 Linux 多个平台,适用于跨平台应用。该包可与富文本、Markdown 和 HTML 编辑器无缝集成。

适合场景

  • 在教育类应用程序中突出显示重要文本
  • 在交互式教程中添加表达性注释
  • 通过手绘风格效果增强用户界面
  • 在仪表板中可视化数据点
  • 创建引人入胜的入门体验
  • 使用动态标记样式化 Markdown 内容

主要特点

  • 动画手绘风格线条
  • 可自定义的描边和填充属性
  • 支持多种注释类型(下划线、框形、圆形)
  • 与 CustomPainter 的内置集成
  • 跨平台兼容性
  • 通过 pub add 命令轻松设置

适合对象

  • 教育和学习应用程序
  • 带有视觉反馈的交互式界面
  • 寻求富有表现力的用户界面元素的设计人员
  • 开发富文本编辑器的开发者
  • 需要趣味或艺术性注释的应用程序

使用建议

  • 可能会影响大量注释的性能
  • 需要了解 CustomPainter 的基础知识
  • 限制为2D画布渲染
  • 不适合高性能动画
  • 最适合静态或低频更新

原始 README

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

RoughNotation Flutter

A lightweight Flutter package to create animated, hand-drawn-style annotations on widgets.

This package recreates the original Rough Notation experience created by Preet Shihn and the contributors.

It uses Flutter’s CustomPainter to render the annotations, supporting config options for styling and animation — including manual triggers, sequencing via groups, and autoplay.

demo-gif


🌐 Playground

See the landing page which has the complete showcase: 👉 roughnotation-flutter.web.app

It showcases all use cases, animation types, groupings, styling controls, and more — all built with Flutter Web.

Explore source in the playground/ folder.


✨ Features

  • Hand-drawn-style annotations
  • Built-in styles:
    • Underline
    • Box
    • Circle
    • Highlight
    • Strike-through
    • Crossed-off
    • Bracket
  • Supports:
    • Autoplay animation
    • Manual triggers
    • Group-based sequencing
    • WidgetSpan for rich text use 38: - iterations for sketchier multi-stroke effect

📦 Installation

flutter pub add rough_notation

🚀 Usage

Basic Annotation
RoughUnderlineAnnotation(
  child: Text('Flutter is fun!'),
  iterations: 3, // Optional: default is 2
)
With Controller (Manual Trigger)
final controller = RoughAnnotationController();

RoughBoxAnnotation(
  controller: controller,
  child: Text('Boxed text'),
);

// Manually trigger
controller.show();

🧹 RichText with WidgetSpan

SelectableText.rich(
  TextSpan(
    text: 'Create a ',
    children: [
      WidgetSpan(
        alignment: PlaceholderAlignment.baseline,
        baseline: TextBaseline.alphabetic,
        child: RoughUnderlineAnnotation(
          child: Text('underline'),
        ),
      ),
      TextSpan(text: ' on a span.'),
    ],
  ),
);

🔄 Grouped Annotations

Use group and sequence to define a group and control animation order.

RoughUnderlineAnnotation(
  group: 'intro',
  sequence: 1,
  child: Text('Step 1'),
);

RoughBoxAnnotation(
  group: 'intro',
  sequence: 2,
  child: Text('Step 2'),
);

// Trigger animation
RoughAnnotationRegistry.showGroup('intro');
Autoplay a Group on Widget Init
@override
void initState() {
  super.initState();
  RoughAnnotationRegistry.markGroupForAutoStart('groupName');
}
✅ Note:
  • It doesn't matter where widgets are in the widget tree — grouped annotations can live inside deeply nested widgets or even different build scopes. The registry handles sequencing regardless of position.
  • From Flutter 3.16+, deferred or conditionally built widgets (e.g., in a ListView.builder) won’t throw errors but will skip animations until built.

Optional:

RoughAnnotationRegistry.showGroup(
  'intro',
  delayBetween: Duration(milliseconds: 300),
);

⚠️ Potential Pitfalls & Edge Cases

  • Delays & Durations: Group sequencing introduces its own delays between elements. Avoid adding large delay values on individual annotations if part of a group.
  • Controllers & Autoplay: If using RoughAnnotationController(autoPlay: true), ensure the widget is built first. Internally, we use addPostFrameCallback to delay the trigger.
  • Multiple Controllers: You can reuse the same controller for multiple widgets, but only one annotation may render if others haven't mounted yet.
  • Lazy Lists / Builders: Widgets in a ListView.builder or similar builders that are not yet mounted will not animate. No crash, but no effect either.
  • Visual Misalignments: Styling mismatches may occur across platforms. Future updates will improve drawing precision and painter logic.

🧠 What's Next

We’re aiming to improve:

  • Core painter logic for smoother lines and curves (lib/src/painters)
  • Extend features and stability of annotation widgets (lib/src/annotations)
  • Also the controllers & grouped behaviour (lib/src/controllers)

The original JS library uses roughjs. Although there's a Flutter version (rough), it’s outdated and Dart 3 incompatible.

We’re considering reviving or reimplementing it in parts. All contributions are welcome!

If you're looking to contribute, ideal places to start are:

  • lib/src/painters/
  • lib/src/annotations/

🙏❤️ Acknowledgements

This Flutter package is heavily inspired by the original Rough Notation JS library.

We acknowledge the original creators and contributors of the JS library — including design, animation logic, and documentation.

We are grateful for the coder’s community and the support of open-source enthusiasts everywhere.


📄 License

MIT


🤝 Contributions

Pull requests are welcome. Let’s make annotations ✏️ in Flutter fun and beautiful.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。