linter icon indicating copy to clipboard operation
linter copied to clipboard

`unnecassary_stack`, `unnecassary_row`, and `unnecassary_column`

Open Number-3434 opened this issue 1 year ago • 2 comments

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!')]),

Number-3434 avatar Jan 14 '24 16:01 Number-3434

@goderbauer

pq avatar Jan 16 '24 14:01 pq

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.

goderbauer avatar Jan 16 '24 19:01 goderbauer