Logo : Forms And Input

Forms And Input

Communauté
zakariaf
forms-and-input

Impose l’utilisation de Form et GlobalKey<FormState> avec TextFormField, dont le validateur synchrone renvoie un String? localisé (jamais un texte codé en dur), et AutovalidateMode.onUserInteraction. Les vérifications asynchrones de disponibilité sont déplacées HORS du validateur synchrone, dans un Notifier Riverpod avec temporisation qui expose les erreurs via l’état. La navigation entre les champs s’appuie sur FocusNode/TextInputAction/onFieldSubmitted ; les champs configurent keyboardType/textCapitalization/autofillHints/TextInputFormatter ; TextEditingController/FocusNode doivent être libérés ; l’activation de l’envoi est dérivée de la validité, et non stockée ; les reconstructions sont limitées pour qu’une frappe ne reconstruise jamais tout le formulaire. À utiliser pour créer un Form, TextFormField ou FormField ; configurer une validation synchrone ou asynchrone ; gérer FocusNode, le parcours du focus, autofocus, TextInputAction, onFieldSubmitted ou onEditingComplete ; définir keyboardType, autofillHints, textCapitalization ou InputFormatter ; libérer TextEditingController/FocusNode ; activer ou désactiver un bouton d’envoi ; ou gérer l’évitement du clavier lors de l’envoi.

Add to TypingMind

Présentation

Éditeurzakariaf
DépôtFlutter-Skills
Nom de la compétenceforms-and-input
Étoiles
64
Forks
15
Fichiers inclus
5
LicenceMIT
Liens
  • Instructions en Markdown

    Un fichier SKILL.md que le modèle charge à la demande : il ne consomme donc des tokens que lorsqu’une demande correspond réellement à la compétence.

  • Compatible avec tous les LLM

    Les compétences IA sont rédigées en Markdown et non sous forme de code propre à un fournisseur. Elles fonctionnent donc avec GPT, Claude, Gemini, Grok ou un modèle local.

  • Fichiers inclus : 5

    Des scripts, des gabarits et des références que le modèle peut consulter pendant son travail. Les fichiers sont en lecture seule et ne sont jamais exécutés.

  • Open source

    Publiée par zakariaf sur GitHub. Consultez les sources avant de l’installer.

Installation

Installez la compétence IA Forms And Input dans TypingMind pour l’utiliser avec n’importe quel LLM, ou ajoutez-la à un autre agent capable de lire SKILL.md.

1

Installer dans TypingMind

TypingMind installe une compétence directement depuis son dossier GitHub : l’application lit SKILL.md, regroupe les fichiers de ressources et enregistre le tout localement.

  1. Ouvrez l’application et accédez à Plugins → Compétences.
  2. Choisissez « Installer depuis GitHub ».
  3. Copiez l’URL ci-dessous, qui pointe vers le dossier de la compétence, puis collez-la et confirmez.
    https://github.com/zakariaf/Flutter-Skills/tree/main/skills/forms-and-input
  4. Activez la compétence dans chaque discussion où vous souhaitez pouvoir l’utiliser.
Plugins → Compétences → Ajouter une compétence → Via une URL GitHub, puis collez l’URL du dossier et appuyez sur Continuer.
2

Installer dans un autre agent

Tout agent capable de lire le format Agent Skills peut utiliser cette compétence : copiez le dossier dans le répertoire des compétences de cet agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zakariaf/Flutter-Skills.git /tmp/Flutter-Skills
mkdir -p .claude/skills
cp -r /tmp/Flutter-Skills/skills/forms-and-input .claude/skills/forms-and-input
Redémarrez Claude Code après la copie pour que la nouvelle compétence soit prise en compte.

Utilisez cette compétence dans TypingMind

Activez Forms And Input dans n’importe quelle discussion TypingMind et le modèle s’occupe du reste. Le nom et la description de la compétence figurent dans le prompt système. Dès qu’une demande correspond, le modèle charge lui-même l’intégralité des instructions : vous n’avez jamais à l’invoquer manuellement, et elle ne consomme aucun token tant qu’elle n’est pas utilisée.

Le modèle charge automatiquement Forms And Input dès qu’une demande correspond à cette compétence.

Compatible avec tous les modèles IA

Les compétences IA sont de simples instructions Markdown, et non du code propre à un fournisseur. Ainsi, la compétence Forms And Input n’est pas liée au modèle pour lequel elle a été conçue. Installez-la une seule fois dans TypingMind et utilisez-la avec GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou un modèle local que vous exécutez vous-même, le tout avec vos propres clés API.

  • Chargée uniquement en cas de besoin

    Le prompt système ne contient que le nom et la description. Les instructions sont récupérées à la première demande correspondante : une compétence inutilisée ne coûte donc rien.

  • Changez de modèle en cours de discussion

    La compétence étant constituée d’instructions et non de code, elle reste fonctionnelle lorsque vous changez de modèle : le nouveau modèle lit le même fichier SKILL.md.

Instructions de la compétence

Voici le contenu de SKILL.md que le modèle charge. Lisez-le avant l’installation : une compétence contient des instructions que votre modèle suivra.

Forms and input

Text input is where most disposal leaks, un-localized strings, and jank enter a Flutter app. A form is a small state machine: fields hold text, a FormState validates them, and a ViewModel owns anything that touches the network or the clock. Keep those three responsibilities separate.

Read the reference for the task at hand:

  • references/validation-sync-and-async.md — sync validator returning localized String?, AutovalidateMode choice, and the debounced-async-in-a-Notifier pattern (why async must NOT live in the sync validator).
  • references/focus-and-keyboard.md — FocusNode lifecycle, traversal order, autofocus, FocusTraversalGroup, TextInputAction, onFieldSubmitted/onEditingComplete, keyboardType, autofillHints, TextInputFormatter, keyboard-avoidance.

Run scripts/check_forms.sh before a PR.

Non-negotiable rules

  1. Every TextEditingController and FocusNode created in a State is disposed in dispose(). They hold native resources and listeners; a leak survives the widget and fires callbacks against a dead tree. If the value must outlive the widget, hold it in a Notifier instead — see state-management-riverpod.
  2. Validator messages are localized, never hardcoded. A validator returns AppLocalizations.of(context).fieldRequired, not 'Required'. Error text is user-facing UI copy and is owned by i18n-rtl-l10n. The check_forms.sh grep fails on string literals returned from a validator.
  3. The sync validator is pure and instant — no await, no network, no Future. FormFieldValidator<T> is String? Function(T?); it cannot be async and Flutter calls it synchronously during layout. Availability/uniqueness checks belong in a Notifier (rule 4).
  4. Async validation lives in a debounced Riverpod Notifier and surfaces through state. Debounce with a dart:async Timer (kept deterministic in tests via fakeAsync, not by the clock), run the check, and expose AsyncValue/a sealed status the field reads via InputDecoration.errorText. Any timestamp the check records comes from ref.read(clockProvider).now(), never DateTime.now() — the Clock seam is owned by service-boundary-and-native. Never block a keystroke on I/O. See async-safety for cancel-on-dispose.
  5. Submit-enabled is DERIVED from validity, never stored as a separate bool. A stored _isValid flag drifts out of sync with the fields. Compute it from FormState/Notifier state at build time. See flutter-performance (derive-don't-store).
  6. A keystroke rebuilds one field, not the whole form. Give each field its own controller/FormField; do not lift raw text into a top-level setState/watch that rebuilds every sibling. Scope rebuilds with small widgets and ref.watch(....select(...)). See widget-composition and flutter-performance.
  7. Choose AutovalidateMode deliberately. Default to AutovalidateMode.onUserInteraction: silent until the user touches a field, then live. Never always (screams before the user types). Validate-on-submit only for short forms where per-field feedback is noise.
  8. Keyboard type, capitalization, and autofill are declared per field. keyboardType, textCapitalization, autofillHints, and TextInputFormatters are structural input contracts, not decoration. A missing autofillHints breaks OS autofill and password managers.
  9. Errors are announced, not just colored. InputDecoration.labelText/errorText carry semantics that screen readers read on change; never signal an error with color alone. See accessibility-as-code.

Form skeleton

Form + a GlobalKey<FormState> is the coordination point. The key lets the submit handler call validate()/save() across all fields at once.

dart
class TaskForm extends StatefulWidget {
  const TaskForm({super.key, required this.onSubmit});
  final void Function(String title) onSubmit;

  @override
  State<TaskForm> createState() => _TaskFormState();
}

class _TaskFormState extends State<TaskForm> {
  final _formKey = GlobalKey<FormState>();
  final _titleController = TextEditingController();
  final _titleFocus = FocusNode();

  @override
  void dispose() {
    _titleController.dispose(); // rule 1: always dispose
    _titleFocus.dispose();
    super.dispose();
  }

  void _submit() {
    if (_formKey.currentState?.validate() ?? false) {
      widget.onSubmit(_titleController.text.trim());
    }
  }

  @override
  Widget build(BuildContext context) {
    final l10n = AppLocalizations.of(context);
    return Form(
      key: _formKey,
      autovalidateMode: AutovalidateMode.onUserInteraction, // rule 7
      child: Column(
        children: [
          TextFormField(
            controller: _titleController,
            focusNode: _titleFocus,
            autofocus: true,
            textInputAction: TextInputAction.done,
            keyboardType: TextInputType.text,
            textCapitalization: TextCapitalization.sentences,
            decoration: InputDecoration(labelText: l10n.taskTitleLabel),
            validator: (value) => // rule 2 + 3: localized, pure
                (value == null || value.trim().isEmpty) ? l10n.fieldRequired : null,
            onFieldSubmitted: (_) => _submit(),
          ),
        ],
      ),
    );
  }
}

Sync validation

The validator is a total, synchronous function of the field value. Return null for valid, a localized message otherwise. Compose small checks; keep the closure short.

dart
String? validateTitle(String? value, AppLocalizations l10n) {
  final text = value?.trim() ?? '';
  if (text.isEmpty) return l10n.fieldRequired;
  if (text.length > 120) return l10n.fieldTooLong; // structural bound, not design
  return null;
}

Async validation (out of the validator)

An availability check (is this account name taken?) is I/O. It runs in a Notifier, debounced against clockProvider, and the field reads the result through errorText. The sync validator stays pure and only guards the shape of the input. Full pattern in references/validation-sync-and-async.md and examples/async_field_notifier.dart.

dart
// The field is driven by Notifier state, not by an async validator.
final status = ref.watch(nameAvailabilityNotifierProvider);
TextFormField(
  controller: _nameController,
  onChanged: ref.read(nameAvailabilityNotifierProvider.notifier).onNameChanged,
  decoration: InputDecoration(
    labelText: l10n.accountNameLabel,
    errorText: switch (status) {
      AsyncData(:final value) when value == NameCheck.taken => l10n.nameTaken,
      AsyncError() => l10n.nameCheckFailed,
      _ => null, // idle / loading / available: no error
    },
  ),
);

Focus and keyboard flow

TextInputAction.next moves to the next field; .done submits. Advance focus in onFieldSubmitted with FocusScope.of(context).nextFocus() or by requesting a specific node. Group related fields with FocusTraversalGroup to control tab order. Details in references/focus-and-keyboard.md.

dart
TextFormField(
  focusNode: _titleFocus,
  textInputAction: TextInputAction.next,
  onFieldSubmitted: (_) => _dueDateFocus.requestFocus(),
),

Submit button derived from validity

Do not store an _isFormValid bool. Derive enablement each build; disable while an async submit is in flight (from Notifier state).

dart
final submitting = ref.watch(taskFormNotifierProvider).isLoading;
FilledButton(
  onPressed: submitting ? null : _submit, // rule 5
  child: Text(l10n.saveAction),
);

Keyboard avoidance

Wrap long forms so the focused field scrolls above the keyboard: a SingleChildScrollView inside the body lets Scaffold (with resizeToAvoidBottomInset: true, the default) push content up. For last-field submit, ensure the submit button is reachable — put it in the scroll view or a bottomNavigationBar.

Anti-patterns

  • validator: (v) async => await repo.isTaken(v) — a validator cannot be async; the Future is truthy so it always "passes." Move to a Notifier (rule 4).
  • Returning 'Required' / 'Invalid email' from a validator — un-localized; breaks every non-English locale. Use AppLocalizations.
  • Creating a TextEditingController/FocusNode in build() — a fresh one every rebuild, losing text and cursor. Create in State, dispose in dispose().
  • bool _isValid toggled in onChanged to enable submit — drifts from real validity. Derive it.
  • autovalidateMode: AutovalidateMode.always — errors shout before the user types a character.
  • One TextEditingController listener that calls setState on the whole form — every keystroke rebuilds every field. Scope the rebuild.
  • debounce timing rolled by hand with DateTime.now() diffs — use a dart:async Timer (deterministic under fakeAsync); and any timestamp the check records comes from ref.read(clockProvider).now(), never DateTime.now().

Definition of done

  • Every controller/FocusNode disposed (or state lives in a Notifier); check_forms.sh clean.
  • No string literal returned from any validator; all messages via AppLocalizations.
  • No await/Future inside a sync validator; async checks in a debounced Notifier surfaced through errorText.
  • AutovalidateMode.onUserInteraction (or an intentional submit-only choice).
  • Submit enablement derived, not stored; disabled during in-flight submit.
  • Each field declares keyboardType, textInputAction, and autofillHints where applicable; focus advances correctly.
  • Errors announced via InputDecoration semantics, never color-only.

Related skills

  • state-management-riverpod — the Notifier that owns async validation and submit state.
  • async-safety — cancel debounce timers/subscriptions on dispose; mounted guards after await.
  • i18n-rtl-l10n — localized validator messages and labels; the non-null AppLocalizations.of(context) getter.
  • accessibility-as-code — field labels, error announcement, never-color-alone, target sizes.
  • flutter-performance — scoped rebuilds and derive-don't-store.
  • widget-composition — small const field widgets over _buildField methods.
  • navigation-and-routing — PopScope for unsaved-changes confirmation when leaving a dirty form.
  • service-boundary-and-native — the Clock seam (clockProvider) any async check reads timestamps from.

References

Fichiers inclus

Le modèle lit ces fichiers à la demande lorsque la compétence est chargée. Ils sont accessibles en lecture et ne sont jamais exécutés.

Foire aux questions

À quoi sert la compétence IA Forms And Input ?

Impose l’utilisation de Form et GlobalKey<FormState> avec TextFormField, dont le validateur synchrone renvoie un String? localisé (jamais un texte codé en dur), et AutovalidateMode.onUserInteraction. Les vérifications asynchrones de disponibilité sont déplacées HORS du validateur synchrone, dans un Notifier Riverpod avec temporisation qui expose les erreurs via l’état. La navigation entre les champs s’appuie sur FocusNode/TextInputAction/onFieldSubmitted ; les champs configurent keyboardType/textCapitalization/autofillHints/TextInputFormatter ; TextEditingController/FocusNode doivent être l...

Pourquoi utiliser Forms And Input sur TypingMind ?

Parce que vous l’installez une seule fois pour l’utiliser avec n’importe quel modèle. Forms And Input se compose de simples instructions en Markdown plutôt que de code propre à un fournisseur. La même compétence fonctionne donc avec GPT-5, Claude, Gemini, Grok ou un modèle local, et vous pouvez changer de modèle en cours de discussion sans perturber son fonctionnement. TypingMind utilise vos propres clés API : vous payez donc directement les fournisseurs plutôt qu’un abonnement par siège, et vos compétences et discussions restent dans votre propre espace de stockage.

Comment installer Forms And Input dans TypingMind ?

Dans TypingMind, ouvrez Plugins → Compétences → Installer depuis GitHub et collez https://github.com/zakariaf/Flutter-Skills/tree/main/skills/forms-and-input. TypingMind lit le fichier SKILL.md, regroupe les fichiers associés et installe le tout sous forme de compétence que vous pouvez activer pour chaque discussion.

Quels modèles d’IA peuvent utiliser Forms And Input ?

N’importe quel modèle que vous connectez dans TypingMind. Les compétences IA sont de simples instructions en Markdown, et non du code propre à un fournisseur. GPT, Claude, Gemini, Grok et les modèles locaux peuvent donc tous charger cette compétence lorsqu’une demande lui correspond.

Combien de modèles d’IA puis-je utiliser avec Forms And Input ?

Autant que vous le souhaitez. Vous pouvez utiliser Forms And Input avec tout modèle qui prend en charge les compétences : GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama et bien d’autres, le tout dans TypingMind avec vos propres clés API.

La compétence IA Forms And Input est-elle gratuite ?

Oui. Cette compétence est publiée sur GitHub par zakariaf sous licence MIT. Vous ne payez que votre propre fournisseur d’IA pour les tokens utilisés.

Que sont les compétences IA ?

Une compétence IA est un ensemble d’instructions réutilisables qui apprend à un modèle d’IA à accomplir une tâche précise. Elle suit le format ouvert Agent Skills : un fichier SKILL.md contenant un nom et une description, ainsi que les éventuels scripts, gabarits ou fichiers de référence dont le modèle peut avoir besoin. Le modèle ne lit les instructions que lorsque votre demande correspond à la compétence. Une compétence installée ne coûte donc rien tant qu’elle n’est pas utilisée.

En quoi les compétences IA diffèrent-elles des plugins ou des serveurs MCP ?

Un plugin ou un serveur MCP fournit au modèle de nouveaux outils à appeler : du code qui s’exécute quelque part et renvoie un résultat. Une compétence IA lui apporte plutôt des connaissances et une méthode : comment aborder une tâche, quelles étapes suivre et à quoi ressemble un bon résultat. Les compétences sont de simples instructions en Markdown. Elles ne nécessitent donc ni serveur, ni clé API, ni environnement d’exécution, et fonctionnent avec n’importe quel modèle.

Tout voir

Créez votre propre espace de travail IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇