Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问许可证需确认审计提醒

flutter-handling-http-and-jsonFlutter handling http AND JSON 命令行

Agent Skill

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

总安装

356

周安装

15

GitHub Stars

公开资料未说明

下载量

125
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/gsmlg-dev/code-agent --skill flutter-handling-http-and-json

简介

该技能用于处理 Flutter 应用中的 HTTP 请求与 JSON 数据交互。

  • 适用于需要发起网络请求、解析或生成 JSON 数据的开发场景。
  • 通过命令行工具集成,支持 Codex、Claude、Cursor 等宿主环境。
  • 安装方式:npx skills add https://github.com/gsmlg-dev/code-agent --skill flutter-handling-http-and-json。
  • 使用前请确认项目依赖和权限范围,避免触发不必要的网络调用。

SKILL.md

Handling HTTP and JSON

Contents

Core Guidelines

  • Enforce HTTPS: iOS and Android disable cleartext (HTTP) connections by default. Always use HTTPS endpoints. If HTTP is strictly required for debugging, configure network_security_config.xml (Android) and NSAppTransportSecurity (iOS).
  • Construct URIs Safely: Always use Uri.https(authority, unencodedPath, [queryParameters]) to safely build URLs. This handles encoding and formatting reliably, preventing string concatenation errors.
  • Handle Status Codes: Always validate the http.Response.statusCode. Treat 200 (OK) and 201 (Created) as success. Throw explicit exceptions for other codes (do not return null).
  • Prevent UI Jank: Move expensive JSON parsing operations (taking >16ms) to a background isolate using the compute() function.
  • Structured AI Output: When integrating LLMs, enforce reliable JSON output by specifying a strict JSON schema in the system prompt and setting the response MIME type to application/json.

Workflow: Executing HTTP Operations

Use this workflow to implement network requests using the http package.

Task Progress:

  • Add the http package to pubspec.yaml.
  • Configure platform permissions (Internet permission in AndroidManifest.xml and macOS .entitlements).
  • Construct the target Uri.
  • Execute the HTTP method.
  • Validate the response and parse the JSON payload.

Conditional Implementation:

  • If fetching data (GET): Use http.get(uri).
  • If sending new data (POST): Use http.post(uri, headers: {...}, body: jsonEncode(data)). Ensure Content-Type is application/json; charset=UTF-8.
  • If updating data (PUT): Use http.put(uri, headers: {...}, body: jsonEncode(data)).
  • If deleting data (DELETE): Use http.delete(uri, headers: {...}).

Feedback Loop: Validation & Error Handling

  1. Run the HTTP request.
  2. Check response.statusCode.
  3. If 200 or 201, call jsonDecode(response.body) and map to a Dart object.
  4. If any other code, throw an Exception('Failed to load/update/delete resource').
  5. Review errors -> fix endpoint, headers, or payload structure.

Workflow: Implementing JSON Serialization

Choose the serialization strategy based on project complexity.

Conditional Implementation:

  • If building a small prototype or simple models: Use manual serialization with dart:convert.
  • If building a production app with complex/nested models: Use code generation with json_serializable.

Manual Serialization Setup

Task Progress:

  • Import dart:convert.
  • Define the Model class with final properties.
  • Implement a factory Model.fromJson(Map<String, dynamic> json) constructor.
  • Implement a Map<String, dynamic> toJson() method.

Code Generation Setup (json_serializable)

Task Progress:

  • Add dependencies: flutter pub add json_annotation and flutter pub add -d build_runner json_serializable.
  • Import json_annotation.dart in the model file.
  • Add the part 'model_name.g.dart'; directive.
  • Annotate the class with @JsonSerializable(). Use explicitToJson: true if the class contains nested models.
  • Define the fromJson factory and toJson method delegating to the generated functions.
  • Run the generator: dart run build_runner build --delete-conflicting-outputs.

Workflow: Parsing Large JSON in the Background

Use this workflow to prevent frame drops when parsing large JSON payloads (e.g., lists of 1000+ items).

Task Progress:

  • Create a top-level or static function that takes a String (the response body) and returns the parsed Dart object (e.g., List<Model>).
  • Inside the function, call jsonDecode and map the results to the Model class.
  • In the HTTP fetch method, pass the top-level parsing function and the response.body to Flutter's compute() function.

Examples

Example 1: HTTP GET with Manual Serialization

import 'dart:convert';
import 'package:http/http.dart' as http;

class Album {
  final int id;
  final String title;

  const Album({required this.id, required this.title});

  factory Album.fromJson(Map<String, dynamic> json) {
    return Album(
      id: json['id'] as int,
      title: json['title'] as String,
    );
  }
}

Future<Album> fetchAlbum() async {
  final uri = Uri.https('jsonplaceholder.typicode.com', '/albums/1');
  final response = await http.get(uri);

  if (response.statusCode == 200) {
    return Album.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
  } else {
    throw Exception('Failed to load album');
  }
}

Example 2: HTTP POST Request

Future<Album> createAlbum(String title) async {
  final uri = Uri.https('jsonplaceholder.typicode.com', '/albums');
  final response = await http.post(
    uri,
    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(<String, String>{'title': title}),
  );

  if (response.statusCode == 201) {
    return Album.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
  } else {
    throw Exception('Failed to create album.');
  }
}

Example 3: Background Parsing with compute

import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;

// 1. Top-level function for parsing
List<Photo> parsePhotos(String responseBody) {
  final parsed = (jsonDecode(responseBody) as List<Object?>)
      .cast<Map<String, Object?>>();
  return parsed.map<Photo>(Photo.fromJson).toList();
}

// 2. Fetch function using compute
Future<List<Photo>> fetchPhotos(http.Client client) async {
  final uri = Uri.https('jsonplaceholder.typicode.com', '/photos');
  final response = await client.get(uri);

  if (response.statusCode == 200) {
    // Run parsePhotos in a separate isolate
    return compute(parsePhotos, response.body);
  } else {
    throw Exception('Failed to load photos');
  }
}

Example 4: Code Generation (json_serializable)

import 'package:json_annotation/json_annotation.dart';

part 'user.g.dart';

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

  @JsonKey(name: 'registration_date_millis')
  final int registrationDateMillis;

  User(this.name, this.registrationDateMillis);

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

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

36.07%
按下载量换算45

Claude

31.54%
按下载量换算39

Cursor

20.37%
按下载量换算25

Gemini CLI

9.21%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

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

安装前确认

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

来源信息

继续浏览同类 Skills