Token导航 LogoToken导航TokenDH.com
开发执行命令github未标认证来源可访问许可证需确认审计提醒

flutter-concurrencyFlutter concurrency 命令行

Agent Skill

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

总安装

23,379

周安装

994

GitHub Stars

1,328

下载量

8,191
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/flutter/skills --skill flutter-concurrency

简介

用于无卡顿 Flutter UI 渲染的后台 JSON 解析和状态管理。

  • 提供决策树用于在手动序列化之间进行选择( dart:convert)和代码生成( json_serialized)基于模型复杂性
  • 支持三种并发策略:主线程 async/await 小负载、短暂的 Isolate.run()
  • 用于繁重的一次性计算,以及与 ReceivePort 的长期隔离
  • / 发送端口
  • 用于持续双向通信
  • 包括平台感知后备:使用compute()
  • 自 dart:isolate 以来适用于 Flutter Web
  • 不支持线程
  • 演示与 FutureBuilder 的集成
  • 用于响应式 UI 状态绑定并强制执行关键约束,例如隔离中无 UI 访问和不可变消息传递

SKILL.md

Flutter Concurrency and Data Management

Goal

Implements advanced Flutter data handling, including background JSON serialization using Isolates, asynchronous state management, and platform-aware concurrency to ensure jank-free 60fps+ UI rendering. Assumes a standard Flutter environment (Dart 2.19+) with access to dart:convert, dart:isolate, and standard state management paradigms.

Decision Logic

Use the following decision tree to determine the correct serialization and concurrency approach before writing code:

  1. Serialization Strategy:

- *Condition:* Is the JSON model simple, flat, and rarely changed? - *Action:* Use Manual Serialization (dart:convert). - *Condition:* Is the JSON model complex, nested, or part of a large-scale application? - *Action:* Use Code Generation (json_serializable and build_runner).

  1. Concurrency Strategy:

- *Condition:* Is the data payload small and parsing takes < 16ms? - *Action:* Run on the Main UI Isolate using standard async/await. - *Condition:* Is the data payload large (e.g., > 1MB JSON) or computationally expensive? - *Action:* Offload to a Background Isolate using Isolate.run(). - *Condition:* Does the background task require continuous, two-way communication over time? - *Action:* Implement a Long-lived Isolate using ReceivePort and SendPort. - *Condition:* Is the target platform Web? - *Action:* Use compute() as a fallback, as standard dart:isolate threading is not supported on Flutter Web.

Instructions

1. Determine Environment and Payload Context

STOP AND ASK THE USER:

  • "Are you targeting Flutter Web, Mobile, or Desktop?"
  • "What is the expected size and complexity of the JSON payload?"
  • "Do you prefer manual JSON serialization or code generation (json_serializable)?"

2. Implement JSON Serialization Models

Based on the user's preference, implement the data models.

Option A: Manual Serialization

import 'dart:convert';

class User {
  final String name;
  final String email;

  User(this.name, this.email);

  User.fromJson(Map<String, dynamic> json)
      : name = json['name'] as String,
        email = json['email'] as String;

  Map<String, dynamic> toJson() => {'name': name, 'email': email};
}

Option B: Code Generation (json_serializable) Ensure json_annotation is in dependencies, and build_runner / json_serializable are in dev_dependencies.

import 'package:json_annotation/json_annotation.dart';

part 'user.g.dart';

@JsonSerializable(explicitToJson: true)
class User {
  final String name;

  @JsonKey(name: 'email_address', defaultValue: 'unknown@example.com')
  final String email;

  User(this.name, this.email);

  factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
  Map<String, dynamic> toJson() => _$UserToJson(this);
}

*Validate-and-Fix:* Instruct the user to run dart run build_runner build --delete-conflicting-outputs to generate the *.g.dart file.

3. Implement Background Parsing (Isolates)

To prevent UI jank, offload heavy JSON parsing to a background isolate.

Option A: Short-lived Isolate (Dart 2.19+) Use Isolate.run() for one-off heavy computations.

import 'dart:convert';
import 'dart:isolate';
import 'package:flutter/services.dart';

Future<List<User>> fetchAndParseUsers() async {
  // 1. Load data on the main isolate
  final String jsonString = await rootBundle.loadString('assets/large_users.json');

  // 2. Spawn an isolate, pass the computation, and await the result
  final List<User> users = await Isolate.run<List<User>>(() {
    // This runs on the background isolate
    final List<dynamic> decoded = jsonDecode(jsonString) as List<dynamic>;
    return decoded.cast<Map<String, dynamic>>().map(User.fromJson).toList();
  });

  return users;
}

Option B: Long-lived Isolate (Continuous Data Stream) Use ReceivePort and SendPort for continuous communication.

import 'dart:isolate';

Future<void> setupLongLivedIsolate() async {
  final ReceivePort mainReceivePort = ReceivePort();

  await Isolate.spawn(_backgroundWorker, mainReceivePort.sendPort);

  final SendPort backgroundSendPort = await mainReceivePort.first as SendPort;

  // Send data to the background isolate
  final ReceivePort responsePort = ReceivePort();
  backgroundSendPort.send(['https://api.example.com/data', responsePort.sendPort]);

  final result = await responsePort.first;
  print('Received from background: $result');
}

static void _backgroundWorker(SendPort mainSendPort) async {
  final ReceivePort workerReceivePort = ReceivePort();
  mainSendPort.send(workerReceivePort.sendPort);

  await for (final message in workerReceivePort) {
    final String url = message[0] as String;
    final SendPort replyPort = message[1] as SendPort;

    // Perform heavy work here
    final parsedData = await _heavyNetworkAndParse(url);
    replyPort.send(parsedData);
  }
}

4. Integrate with UI State Management

Bind the asynchronous isolate computation to the UI using FutureBuilder to ensure the main thread remains responsive.

import 'package:flutter/material.dart';

class UserListScreen extends StatefulWidget {
  const UserListScreen({super.key});

  @override
  State<UserListScreen> createState() => _UserListScreenState();
}

class _UserListScreenState extends State<UserListScreen> {
  late Future<List<User>> _usersFuture;

  @override
  void initState() {
    super.initState();
    _usersFuture = fetchAndParseUsers(); // Calls the Isolate.run method
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Users')),
      body: FutureBuilder<List<User>>(
        future: _usersFuture,
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting) {
            return const Center(child: CircularProgressIndicator());
          } else if (snapshot.hasError) {
            return Center(child: Text('Error: ${snapshot.error}'));
          } else if (!snapshot.hasData || snapshot.data!.isEmpty) {
            return const Center(child: Text('No users found.'));
          }

          final users = snapshot.data!;
          return ListView.builder(
            itemCount: users.length,
            itemBuilder: (context, index) {
              return ListTile(
                title: Text(users[index].name),
                subtitle: Text(users[index].email),
              );
            },
          );
        },
      ),
    );
  }
}

Constraints

  • No UI in Isolates: Never attempt to access dart:ui, rootBundle, or manipulate Flutter Widgets inside a spawned isolate. Isolates do not share memory with the main thread.
  • Web Platform Limitations: dart:isolate is not supported on Flutter Web. If targeting Web, you MUST use the compute() function from package:flutter/foundation.dart instead of Isolate.run(), as compute() safely falls back to the main thread on web platforms.
  • Immutable Messages: When passing data between isolates via SendPort, prefer passing immutable objects (like Strings or unmodifiable byte data) to avoid deep-copy performance overhead.
  • State Immutability: Always treat Widget properties as immutable. Use StatefulWidget and setState (or a state management package) to trigger rebuilds when asynchronous data resolves.
  • Reflection: Do not use dart:mirrors for JSON serialization. Flutter disables runtime reflection to enable aggressive tree-shaking and AOT compilation. Always use manual parsing or code generation.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

35.37%
按下载量换算2,897

Claude

31.34%
按下载量换算2,567

Cursor

20.15%
按下载量换算1,650

Gemini CLI

10.03%
按下载量换算822

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/flutter/skills --skill flutter-concurrency 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

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

来源信息

继续浏览同类 Skills