avoid-wrapping-in-padding
- Group
- Style
- Path
lint/style/avoid-wrapping-in-padding- Default
- Off, opt in
- Origin
- Falcon
- Domain
- flutter
- Rule
- 189 of 512
Flags Padding directly wrapping a Flutter Container that can own the padding. Containers with existing padding, margin, alignment, sizing, constraints, transforms, color, decoration or foregroundDecoration are excluded: moving padding across those layout and paint stages can change the result. Non-null keys on either widget are excluded because the keyed element's bounds change. This is distinct from prefer-padding-over-container and prefer-container's three-widget layout sequence.
Invalid
import 'package:flutter/widgets.dart';
import 'package:flutter/widgets.dart' as f;
typedef P = Padding;
void callback() {}
void examples(Widget child, dynamic image, dynamic color, double size, String label) {
Padding(padding: 1, child: Container(child: child));
Padding(padding: 2, child: Container(key: null, child: child));
new Padding(padding: 3, child: Container());
f.Padding(padding: 4, child: f.Container(child: child));
P(padding: 5, child: Container(child: child));
Padding(key: null, padding: 1, child: Container(child: child));
Padding(key: (null), padding: 1, child: Container(key: (null), child: child));
}void examples(Widget child, dynamic image, dynamic color, double size, String label) { Padding(padding: 1, child: Container(child: child)); Padding(padding: 1, child: Container(child: child)); Padding(padding: 2, child: Container(key: null, child: child)); Padding(padding: 2, child: Container(key: null, child: child)); new Padding(padding: 3, child: Container()); new Padding(padding: 3, child: Container()); f.Padding(padding: 4, child: f.Container(child: child)); f.Padding(padding: 4, child: f.Container(child: child)); P(padding: 5, child: Container(child: child)); P(padding: 5, child: Container(child: child)); Padding(key: null, padding: 1, child: Container(child: child)); Padding(key: null, padding: 1, child: Container(child: child)); Padding(key: (null), padding: 1, child: Container(key: (null), child: child));Valid
import 'package:flutter/widgets.dart';
import 'package:flutter/widgets.dart' as f;
typedef P = Padding;
void callback() {}
void examples(Widget child, dynamic image, dynamic color, double size, String label) {
Padding(padding: 1, child: SizedBox());
Padding(padding: 1, child: Container(padding: 2));
Padding(padding: 1, child: Container(width: 20));
Padding(padding: 1, child: Container(margin: 2));
Padding(padding: 1, child: Container(color: color));
Padding(padding: 2, child: Container(key: image, child: child));
Padding(key: image, padding: 1, child: Container(child: child));
Padding(key: image, padding: 1, child: Container(key: color, child: child));
Padding(key: null, padding: 1, child: Container(key: image, child: child));
Padding(key: image, padding: 1, child: Container(key: null, child: child));
f.Padding(key: image, padding: 1, child: f.Container(child: child));
P(key: image, padding: 1, child: Container(child: child));
}Configure avoid-wrapping-in-padding
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"avoid-wrapping-in-padding": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/avoid-wrapping-in-padding: <reason>More style rules
- binary-expression-operand-order
binary-expression-operand-orderFlags comparison expressions with a literal on the left-hand side.
- boolean-prefixes
boolean_prefixesFlags boolean identifiers that lack a conventional interrogative prefix.
- camel-case-extensions
camel_case_extensionsrecommendedFlags named extensions whose name is not
UpperCamelCase. - camel-case-types
camel_case_typesrecommendedFlags type names that are not
UpperCamelCase. - cast-nullable-to-non-nullable
cast_nullable_to_non_nullableFlags
e as Tcasts of a nullable value to a non-nullable type. - class-members-ordering
class_members_orderingFlags class members declared out of a canonical order.
- combinators-ordering
combinators_orderingFlags
show/hidecombinators whose names are not sorted alphabetically. - conditional-uri-does-not-exist
conditional_uri_does_not_existrecommendedRequire the targets of conditional import and export URIs to exist.