avoid-border-all
- Group
- Performance
- Path
lint/performance/avoid-border-all- Default
- Off, opt in
- Origin
- Falcon
- Domain
- flutter
- Rule
- 26 of 512
Avoids Flutter's non-const Border.all factory. Use
Border.fromBorderSide(const BorderSide(...)) when the side is constant.
Only invocations whose arguments can all be constant qualify.
Invalid
import 'package:flutter/widgets.dart';
import 'package:flutter/widgets.dart' as f;
typedef B = Border;
void callback() {}
void examples(Widget child, dynamic image, dynamic color, double size, String label) {
Border.all();
Border.all(width: 2);
new Border.all();
f.Border.all(color: 0xff112233);
B.all(width: 3);
}void examples(Widget child, dynamic image, dynamic color, double size, String label) { Border.all(); Border.all(); Border.all(width: 2); Border.all(width: 2); new Border.all(); new Border.all(); f.Border.all(color: 0xff112233); f.Border.all(color: 0xff112233); B.all(width: 3);Valid
import 'package:flutter/widgets.dart';
import 'package:flutter/widgets.dart' as f;
typedef B = Border;
void callback() {}
void examples(Widget child, dynamic image, dynamic color, double size, String label) {
const Border();
const Border.fromBorderSide(BorderSide());
Border.fromBorderSide(BorderSide(width: 2));
f.Border();
const B();
}Configure avoid-border-all
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"performance": {
"avoid-border-all": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/performance/avoid-border-all: <reason>More performance rules
- avoid-shrink-wrap-in-listsflutter
Avoids shrink-wrapped Flutter lists nested in rows, columns, or other lists.
- avoid-slow-async-io
avoid_slow_async_ioAvoid the slow asynchronous
dart:iofile-system queries. - avoid-slow-collection-methods
Reports filtered iterable searches that have a direct search-method alternative.
- avoid-unnecessary-collections
Avoid singleton collection literals where SDK APIs accept a single value.
- avoid-unnecessary-consumer-widgetsriverpod
Flags Riverpod consumer widgets whose build reference is unused.
- avoid-unnecessary-futures
Prefer synchronous declarations when an async Future only returns scalars.
- avoid-unnecessary-gesture-detectorflutter
Flags handler-free Flutter
GestureDetectorsand tap-only wrappers around enabled Flutter buttons. - avoid-unnecessary-hook-widgetsflutter_hooks
Flags confirmed hook widgets and
HookBuildercallbacks that do not use hooks.