avoid-missing-controller
- Group
- Correctness
- Path
lint/correctness/avoid-missing-controller- Default
- Off, opt in
- Origin
- Falcon
- Domain
- flutter
- Rule
- 85 of 512
Require Flutter text fields to expose their updated value.
TextField, TextFormField, CupertinoTextField, and EditableText need a non-null
controller or a value callback supported by that API. Explicit readOnly:true
and enabled:false fields are display-only and skipped. Dynamic expressions
are accepted; unrelated classes and shadowed constructors are ignored.
Invalid
import 'package:flutter/material.dart';
import 'package:flutter/material.dart' as f;
void fields() {
TextField();
TextFormField();
f.CupertinoTextField.borderless();
new EditableText(controller: null);
TextField(controller: null, onChanged: null);
TextFormField(onSaved: null);
}void fields() { TextField(); TextField(); TextFormField(); TextFormField(); f.CupertinoTextField.borderless(); f.CupertinoTextField.borderless(); new EditableText(controller: null); new EditableText(controller: null); TextField(controller: null, onChanged: null); TextField(controller: null, onChanged: null); TextFormField(onSaved: null);Valid
import 'package:flutter/material.dart';
import 'package:flutter/material.dart' as f;
void fields(Object? controller, Function callback) {
TextField(controller: controller);
TextFormField(onChanged: callback);
f.CupertinoTextField.borderless(onSubmitted: callback);
EditableText(onChanged: callback);
TextFormField(onSaved: callback);
TextFormField(onFieldSubmitted: callback);
TextField(controller: TextEditingController());
TextField(readOnly: true);
TextFormField(enabled: false);
CupertinoTextField.borderless(readOnly: true);
EditableText(readOnly: true);
}
void shadow(dynamic TextField) { TextField(); }Configure avoid-missing-controller
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"correctness": {
"avoid-missing-controller": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/correctness/avoid-missing-controller: <reason>More correctness rules
- avoid-missing-enum-constant-in-map
Require enum-keyed map literals to include every declared enum value.
- avoid-missing-interpolationrecommended
Flags missing interpolation around visible String variables or member accesses and calls.
- avoid-misused-hooksrecommendedflutter_hooks
Flags confirmed Flutter hooks called directly in non-hook Flutter widget builds.
- avoid-mounted-in-setstateflutter
Check mounted before invoking Flutter State.setState, never inside its callback.
- avoid-mutable-equatable-subclass-fieldsrecommendedequatable
Flags mutable instance fields on subclasses inheriting Equatable equality.
- avoid-mutable-global-variables
avoid_mutable_global_variablesDisallow mutable top-level variables.
- avoid-nested-futures
Avoid
Future<Future<T>>,FutureOr<Future<T>>, and other directly nested future wrappers. - avoid-nested-streams-and-futures
Avoid directly nesting SDK streams and futures:
Stream<Future<T>>andFuture<Stream<T>>complicate consumption.