AgentSkillsCN

flutter-skill

掌握Flutter开发技能,熟悉UI/UX设计规范、状态管理、路由配置以及API集成。在开发Flutter应用、与设计、UI、UX、布局、Provider、GoRouter、i18n、FCM或Firebase Auth等模块协同工作时使用。(项目)

SKILL.md
--- frontmatter
name: flutter-skill
description: |
  Flutter development skill with UI/UX guidelines, state management, routing, and API integration. Use when developing Flutter apps, working with design, UI, UX, layouts, Provider, GoRouter, i18n, FCM, or Firebase Auth. (project)

Flutter Skill

This skill provides universal guidelines for Flutter framework app development including UI/UX design, state management, networking, and API integration. It provides essential instructions that must be followed, not optional information.

Table of Contents

Workflow

Follow this workflow based on developer requests:

  1. Design/UI/UX requests: See Comic Design

    • Keywords: design, UI, UX, buttons, cards, layout, animation, Comic
  2. Layout requests: See Flutter Layout

    • Keywords: layout, scroll, CustomScrollView, ListView, widget placement
  3. State management requests: See Provider

    • Keywords: state management, Provider, Selector, ChangeNotifier
  4. Routing requests: See Go Route

    • Keywords: routing, navigation, GoRouter, page navigation
  5. Internationalization requests: See i18n

    • Keywords: i18n, translation, localization, arb

Core Principles

Mandatory Rules

dart
// ❌ NEVER DO THIS
color: Colors.blue              // Hardcoded color
fontSize: 16                    // Hardcoded size
Text('Hello')                   // Hardcoded text
elevation: 4                    // Non-zero elevation

// ✅ ALWAYS DO THIS
color: Theme.of(context).colorScheme.primary  // Theme color
style: Theme.of(context).textTheme.bodyLarge  // Theme text style
Text(T.hello)                                  // i18n translation
elevation: 0                                   // Flat design

Theme-based Styling

All colors, fonts, and styles must use Theme.of(context):

UsageUsage Method
Primary colorTheme.of(context).colorScheme.primary
Surface colorTheme.of(context).colorScheme.surface
Border colorTheme.of(context).colorScheme.outline
Body textTheme.of(context).textTheme.bodyLarge
Title textTheme.of(context).textTheme.titleMedium

Comic Design Summary

PropertyValueDescription
Border Width2.0 (standard), 1.0 (list)Comic style border
Border Radius12Rounded corners
Elevation0No shadow
SpacingMultiple of 88, 16, 24, 32...

Reference Documents

DocumentContent
comic-design.mdComic UI design system, buttons, cards, forms, SnackBar
flutter-layout.mdScroll screens, CustomScrollView, ListView patterns
provider.mdProvider state management, Selector, ChangeNotifier
go_route.mdGoRouter routing, parameter passing, redirect
i18n.mdInternationalization, ARB file management

Required pub.dev Packages

file_cache_flutter

File cache library for Flutter applications with memory + file dual caching and TTL-based auto-expiration.

Quick Reference

Imports

dart
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:provider/provider.dart';
import 'package:go_router/go_router.dart';

Animation (using flutter_animate)

dart
Container()
  .animate()
  .fadeIn(duration: 300.ms)
  .slideX(begin: -0.2, end: 0)

Icon Priority

When using Font Awesome Pro icons, priority: Light > Regular > Solid

dart
FaIcon(FontAwesomeIcons.lightCamera)  // Light first