add-home-widget-selector

Add configurable HomeWidget selectors to Flutter plugins with navigation hooks.

70|12|Updated Apr 1, 2025
One-click install
npx skills add https://github.com/hunmer/Memento --skill add-home-widget-selector
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-home-widget-selector
Source: https://github.com/hunmer/Memento/tree/main/.claude/skills/add-home-widget-selector
Command: npx skills add https://github.com/hunmer/Memento --skill add-home-widget-selector

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flutter 插件常常缺少可在首页直接访问的数据入口,开发者需要重复实现数据选择、渲染与导航逻辑。本 Skill 提供一个可配置的 HomeWidget 方案,帮助插件快速暴露可定制的小组件。

Core Features & Use Cases

  • 数据选择与持久化:通过 dataSelector 提取并保存必要字段(如 item id),避免冗余数据。
  • 动态渲染与最新数据:通过 dataRenderer 使用插件控制器按 ID 获取最新数据,确保 UI 一致性。
  • 导航与详情页:内置 navigationhook,点击小组件可跳转到相应的详情屏幕,提升用户体验。
  • Use Case: 为一个待办插件添加“今日待办入口”小组件,自动显示选中的任务标题与状态,并可进入任务详情页。

Quick Start

按照以下步骤快速将一个插件转变为可配置的 HomeWidget:

  1. 在插件初始化阶段注册数据选择器(dataSelector),并创建 home_widgets.dart 注册小组件。
  2. 实现 dataSelector,确保返回一个包含至少 id 的 Map<String, dynamic>。
  3. 实现 dataRenderer,通过插件控制器的 getItemById(id) 获取最新数据并渲染 UI。
  4. 实现 navigationHandler,点击小组件时跳转到该数据的详情页。
  5. 在插件主注册流程中注册该 HomeWidget。
  6. 在路由配置中添加详情页路由,以便导航。
  7. 为插件添加国际化字符串,确保 UI 文案可本地化。

Frequently Asked Questions about add-home-widget-selector

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a configurable HomeWidget to a Flutter plugin?

To add a configurable HomeWidget to a Flutter plugin, you must implement a dataSelector to extract and save an item ID, a dataRenderer to fetch and display the latest data via the plugin controller, and a navigation hook to push the detail route on tap.

How does data rendering work for Flutter HomeWidgets?

Data rendering for Flutter HomeWidgets works by using a dataRenderer function that calls the plugin controller to fetch the latest data by item ID, ensuring the UI displays the most current information without storing redundant data.

Do I need to set up navigation routes to use HomeWidgets in Flutter?

Yes, you need to set up navigation routes to use HomeWidgets in Flutter. A navigationHandler must be implemented to push the user to the respective detail screen when the HomeWidget is tapped.

What is the best way to persist HomeWidget data in a Flutter plugin?

The best way to persist HomeWidget data in a Flutter plugin is using a dataSelector to extract and save only necessary fields, such as the item ID, in a Map<String, dynamic> format, avoiding redundant data storage.

Can I add internationalization to Flutter HomeWidgets?

Yes, you can add internationalization to Flutter HomeWidgets. You should add internationalization strings during the registration process to ensure the UI copy can be localized for different regions.