avoid-single-child-column-or-row
Same as avoid_single_child_column_or_row in Pyramid Lint
- Group
- Style
- Path
lint/style/avoid-single-child-column-or-row- Default
- Off, opt in
- Origin
- Pyramid Lint
- Domain
- flutter
- Rule
- 141 of 512
Flags a Column, Row, or Flex widget built with a single child.
A multi-child layout widget that wraps exactly one child adds a layout node
and an allocation without changing what is rendered; the child can be used
directly, or swapped for Align, Center, or Padding if the axis
behavior actually mattered. The rule fires only when the children list
holds exactly one expression element, and it tolerates partially-parsed Dart
3 collection elements by requiring a complete, )-terminated construction.
Invalid
import 'package:flutter/material.dart';
Widget a() => Column(children: [Text('a')]);
Widget b() => Row(children: [Icon(Icons.add)]);
Widget c() =>
Flex(direction: Axis.vertical, children: [SizedBox()]);
Widget d() => Column(children: [const Divider()]);
Widget e() => const Row(children: [Text('x')]); Widget a() => Column(children: [Text('a')]); Widget b() => Row(children: [Icon(Icons.add)]);Widget c() => Flex(direction: Axis.vertical, children: [SizedBox()]); Widget d() => Column(children: [const Divider()]); Widget e() => const Row(children: [Text('x')]);Valid
import 'package:flutter/material.dart';
Widget a() => Column(children: [Text('a'), Text('b')]);
Widget b() => Row(children: []);
Widget c() => Column(children: [...items]);
Widget d() => SizedBox(child: Text('a'));
Widget e() =>
Column(mainAxisSize: MainAxisSize.min, children: [Text('a'), Icon(Icons.add)]);
Widget f() => Wrap(children: [Text('a')]);
const items = <Widget>[];Configure avoid-single-child-column-or-row
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"avoid-single-child-column-or-row": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/avoid-single-child-column-or-row: <reason>More style rules
- avoid-top-level-member-access
Flags mutable global state: non-
const, non-finaltop-level variables and static fields, plus every read of mutable top-level variables. - avoid-types-on-closure-parameters
avoid_types_on_closure_parametersFlags type annotations on closure parameters whose types come from context.
- avoid-unnecessary-block
Flags standalone nested blocks that introduce no lexical declarations.
- avoid-unnecessary-call
Prefer direct invocation of functions and resolved callable instances.
- avoid-unnecessary-continue
Flags an unlabeled continue at the end of a loop body or its final branch.
- avoid-unnecessary-getter
Flags a getter that only exposes a private final field.
- avoid-unnecessary-if
Flags an if branch that only returns the same expression as the following return.
- avoid-unnecessary-length-check
Empty collections already skip
for-inandforEachbodies.