AGENT SKILL

flutter-building-forms

Builds Flutter forms with validation and user input handling. Use when creating login screens, data entry forms, or any multi-field user input.

License 许可
MIT
最近更新
2026-06-13
Stars
★ 3
Forks
1

01 前言 Front Matter

name
flutter-building-forms
description
Builds Flutter forms with validation and user input handling. Use when creating login screens, data entry forms, or any multi-field user input.

03 SKILL.md 正文

Building Validated Forms

Contents

Form Architecture

Implement forms using a Form widget to group and validate multiple input fields together.

  • Use a StatefulWidget: Always host your Form inside a StatefulWidget.
  • Persist the GlobalKey: Instantiate a GlobalKey<FormState> exactly once as a final variable within the State class. Do not generate a new GlobalKey inside the build method.
  • Bind the Key: Pass the GlobalKey<FormState> to the key property of the Form widget.
  • Alternative Access: Use Form.of(context) to access the FormState from a descendant widget.

Field Validation

Use TextFormField for Material Design text inputs with built-in validation.

  • Implement the Validator: Provide a validator() callback to each TextFormField.
  • Return Error Messages: If invalid, return a String with the error message.
  • Return Null for Success: If valid, return null.

Workflow: Implementing a Validated Form

  • [ ] Create a StatefulWidget and its State class.
  • [ ] Instantiate final _formKey = GlobalKey<FormState>(); in the State class.
  • [ ] Return a Form widget in build and assign key: _formKey.
  • [ ] Add TextFormField widgets as descendants of the Form.
  • [ ] Write a validator function for each field (return String on error, null on success).
  • [ ] Add a submit button.
  • [ ] Validate in onPressed using _formKey.currentState!.validate().

Validation Decision Logic

  1. Call _formKey.currentState!.validate().
  2. If true: Proceed with submission (save data, API call) and show success (SnackBar).
  3. If false: Error messages display automatically. User adjusts input and resubmits.

Examples

Complete Validated Form

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

  @override
  State<UserRegistrationForm> createState() => _UserRegistrationFormState();
}

class _UserRegistrationFormState extends State<UserRegistrationForm> {
  final _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return Form(
      key: _formKey,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          TextFormField(
            decoration: const InputDecoration(
              labelText: 'Username',
              hintText: 'Enter your username',
            ),
            validator: (value) {
              if (value == null || value.isEmpty) {
                return 'Please enter a username';
              }
              if (value.length < 4) {
                return 'Username must be at least 4 characters';
              }
              return null;
            },
          ),
          const SizedBox(height: 16),
          ElevatedButton(
            onPressed: () {
              if (_formKey.currentState!.validate()) {
                ScaffoldMessenger.of(context).showSnackBar(
                  const SnackBar(content: Text('Processing Data')),
                );
              }
            },
            child: const Text('Submit'),
          ),
        ],
      ),
    );
  }
}

04 同仓库更多 Skills

openplaybooks-dev
openplaybooks-dev/converge

hello-checker

Use this skill when asked to "verify", "check", or "validate" a file's existence and content. It provides a reliable workflow for confirming files meet their spec.

Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

ask-skill

暂无简介

Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

html-review-artifact

Framework-wide guidance for crafting polished human-review artifacts as markdown or HTML

前端开发Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

converge-planning

Design a Converge playbook end-to-end. Use when the user says "plan a project", "design a playbook", "decompose into tasks", "scaffold a Converge workflow", "onboard to Converge", or asks how to write TASK.md / playbook.yml. Two entry points: plan a new playbook or update an existing one. Hand off to `/converge-control` after producing the playbook structure.

Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

converge-control

Operate a Converge playbook end-to-end — start runs, monitor progress, narrow failures with `--select`, inspect runtime state, validate definitions, surgically reset subtrees, and stop stuck or orphaned runs. Use this skill whenever the user says "run my playbook", "execute this", "monitor the run", "converge failed", "the run is stuck", "retry failures", "babysit this playbook", "what's the status?", "show me the gantt", or asks how to use `converge run` / `--select` / `inspect` / `doctor` / `clean` / `stop`. Also use it for `HTTP 401` / `Invalid API key` failures on the first task — those are environment-not-playbook problems — and for any post-run cleanup work. Hand off to `converge-planning` if the user wants to design or restructure the playbook itself.

开发工程师Skill与智能体开发
★ 3
openplaybooks-dev
openplaybooks-dev/converge

repair-taskts

Fix task.ts definition issues — Seed syntax, missing .build(), empty checks, import errors, TypeScript errors

开发工程师
★ 3