Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

flutter-home-screen-widgetFlutter home screen widget 命令行

Agent Skill

flutter-home-screen-widget 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

12,949

周安装

545

GitHub Stars

1,310

下载量

4,534
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:flutter-home-screen-widget(Flutter home screen widget 命令行)
来源仓库:https://github.com/flutter/skills
仓库路径:skills/flutter-home-screen-widget
安装命令:
npx skills add https://github.com/flutter/skills --skill flutter-home-screen-widget
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/flutter/skills --skill flutter-home-screen-widget

简介

适用于 iOS 和 Android 上 Flutter 应用程序的本机主屏幕小部件,具有跨平台数据共享功能。

  • 通过应用程序组 (iOS) 和 SharedPreferences (Android) 在 Dart 和本机平台之间建立数据共享,从而可以从 Flutter 应用程序更新小部件
  • 支持简单的基于文本的小部件和复杂的 Flutter UI 呈现为静态图像以进行本机显示
  • 需要在 Xcode(带有 Swift TimelineProvider 的 Widget Extension 目标)和 Android Studio(带有 XML 布局和 Kotlin 实现的 AppWidgetProvider)中进行本机设置
  • 应用程序组 ID 和小部件名称必须在 Dart、Swift 和 Kotlin 中完全匹配;本机代码更改需要完全重建并在主屏幕上重新添加小部件

SKILL.md

flutter-home-screen-widgets

Goal

Implements native home screen widgets (iOS and Android) for a Flutter application using the home_widget package. It establishes data sharing between the Dart environment and native platforms via App Groups (iOS) and SharedPreferences (Android), enabling text updates and rendering Flutter UI components as images for native display. Assumes a pre-existing Flutter project environment with native build tools (Xcode and Android Studio) configured.

Instructions

  1. Initialize Dependencies Add the home_widget package to the Flutter project. flutter pub add home_widget flutter pub get
  2. Decision Logic: Platform & Feature Selection Determine the target platforms and required widget capabilities. [BLOCKING] User Consultation BEFORE performing any implementation, you MUST ask: *Flowchart:*

- "Which platforms are you targeting?" - "Do you need simple text or complex UI?" - If iOS -> Proceed to Step 4 (iOS Native Setup). - If Android -> Proceed to Step 5 (Android Native Setup). - If rendering Flutter UI as images -> Proceed to Step 6 after basic setup.

  1. Implement Dart Data Sharing Logic Create the Dart logic to save data to the native key/value store and trigger widget updates. import 'package:home_widget/home_widget.dart'; // Replace with actual App Group ID for iOS const String appGroupId = 'group.com.yourcompany.app'; const String iOSWidgetName = 'NewsWidgets'; const String androidWidgetName = 'NewsWidget'; Future<void> updateWidgetData(String title, String description) async {await HomeWidget.setAppGroupId(appGroupId); await HomeWidget.saveWidgetData<String>('headline_title', title); await HomeWidget.saveWidgetData<String>('headline_description', description); await HomeWidget.updateWidget(iOSName: iOSWidgetName, androidName: androidWidgetName,);}
  2. iOS Native Setup (If applicable) import WidgetKit import SwiftUI struct NewsArticleEntry: TimelineEntry {let date: Date let title: String let description: String} struct Provider: TimelineProvider {func placeholder(in context: Context) -> NewsArticleEntry {NewsArticleEntry(date: Date(), title: "Placeholder Title", description: "Placeholder description")} func getSnapshot(in context: Context, completion: @escaping (NewsArticleEntry) -> ()) {let entry: NewsArticleEntry if context.isPreview {entry = placeholder(in: context)} else {// Replace with actual App Group ID let userDefaults = UserDefaults(suiteName: "group.com.yourcompany.app") let title = userDefaults?.string(forKey: "headline_title")?? "No Title Set" let description = userDefaults?.string(forKey: "headline_description")?? "No Description Set" entry = NewsArticleEntry(date: Date(), title: title, description: description)} completion(entry)} func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {getSnapshot(in: context) {(entry) in let timeline = Timeline(entries: [entry], policy:.atEnd) completion(timeline)}}} struct NewsWidgetsEntryView: View {var entry: Provider.Entry var body: some View {VStack(alignment:.leading) {Text(entry.title).font(.headline) Text(entry.description).font(.subheadline)}}} *Validate-and-Fix:* Run flutter build ios --config-only to ensure the Flutter configuration syncs with the new Xcode targets. If build fails, verify the App Group ID matches exactly between Dart and Swift.

- Configure an App Group in Xcode for both the Runner target and the Widget Extension target. - Create a Widget Extension target in Xcode (e.g., NewsWidgets). Uncheck "Include Live Activity" and "Include Configuration Intent". - Implement the TimelineProvider and View in Swift:

  1. Android Native Setup (If applicable) <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/widget_container" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"> <TextView android:id="@+id/headline_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Title" android:textStyle="bold" android:textSize="20sp" /> <TextView android:id="@+id/headline_description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/headline_title" android:text="Description" android:textSize="16sp" /> </RelativeLayout> package com.yourdomain.yourapp import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetProvider import android.content.Context import android.widget.RemoteViews import es.antonborri.home_widget.HomeWidgetPlugin class NewsWidget: AppWidgetProvider() {override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {for (appWidgetId in appWidgetIds) {val widgetData = HomeWidgetPlugin.getData(context) val views = RemoteViews(context.packageName, R.layout.news_widget).apply {val title = widgetData.getString("headline_title", null) setTextViewText(R.id.headline_title, title?: "No title set") val description = widgetData.getString("headline_description", null) setTextViewText(R.id.headline_description, description?: "No description set")} appWidgetManager.updateAppWidget(appWidgetId, views)}}}

- Create an AppWidgetProvider in Android Studio (New -> Widget -> App Widget). - Define the XML layout (res/layout/news_widget.xml): - Implement the Kotlin Provider (NewsWidget.kt):

  1. Render Flutter Widgets as Images (Optional) If the user requires complex UI (like charts) on the widget, render the Flutter widget to a PNG and pass the file path. *Dart Implementation:* final _globalKey = GlobalKey(); // Wrap your target widget with a RepaintBoundary/Key // Center(key: _globalKey, child: const LineChart()) Future<void> renderAndSaveWidget() async {if (_globalKey.currentContext!= null) {var path = await HomeWidget.renderFlutterWidget(const LineChart(), fileName: 'screenshot', key: 'filename', logicalSize: _globalKey.currentContext!.size, pixelRatio: MediaQuery.of(_globalKey.currentContext!).devicePixelRatio,); await HomeWidget.updateWidget(iOSName: iOSWidgetName, androidName: androidWidgetName);}} *Native Image Loading (Android Example):* // Inside RemoteViews apply block: val imageName = widgetData.getString("filename", null) val imageFile = java.io.File(imageName) if (imageFile.exists()) {val myBitmap = android.graphics.BitmapFactory.decodeFile(imageFile.absolutePath) setImageViewBitmap(R.id.widget_image, myBitmap)}

Constraints

  • Immutable Native Identifiers: The iOSName and androidName in Dart MUST exactly match the Swift struct name and Kotlin class name respectively.
  • App Group Prefix: iOS App Group IDs MUST be prefixed with group. and match exactly in Xcode capabilities, Swift UserDefaults(suiteName:), and Dart HomeWidget.setAppGroupId().
  • No Direct Flutter UI: Never attempt to render Flutter widgets directly in the native widget lifecycle. You MUST use renderFlutterWidget to generate a static image if complex UI is required.
  • Full Re-run Required: Changing native code (PendingIntents, Layouts, Manifest) requires a full flutter run.
  • Widget Re-add: After native changes, it is often necessary to remove and re-add the widget on the home screen for changes to take effect.
  • Android Cell Sizing: Android widget dimensions in res/xml/*_info.xml must be calculated in cells (e.g., minWidth="250dp"). Do not use arbitrary pixel values.
  • Validate-and-Fix: Always instruct the user to run native builds (flutter build ios / flutter build apk) after modifying native files to catch syntax or linking errors immediately.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.87%
按下载量换算1,581

Claude

30.51%
按下载量换算1,383

Cursor

19.42%
按下载量换算881

Gemini CLI

11.16%
按下载量换算506

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills