linter
linter copied to clipboard
`unnecassary_stack`, `unnecassary_row`, and `unnecassary_column`
Lint that informs when a Stack
, Row
, or Column
only has a single child in the children
parameter.
// BAD, has only one child in children
const Stack(children: [Text('Hello World!')]),
const Row(children: [Text('Hello World!')]),
const Column(children: [Text('Hello World!')]),
// GOOD, has more than one child in children
const Stack(children: [Text('Hello World!'), Text('Hello World Again!')]),
const Row(children: [Text('Hello World!'), Text('Hello World Again!')]),
const Column(children: [Text('Hello World!'), Text('Hello World Again!')]),
@goderbauer
This would be sort of similar to the avoid_unnecessary_containers
. I wouldn't be opposed to this lint existing, but I also wonder how much value it would bring. Would be interesting to see how many unnecessary widgets of those types exist in a larger code base. Unlike unnecessary containers I haven't seen many (any?) of these cases in code reviews.