prefer-transform-over-container
Suggests using a Transform
widget instead of the Container
widget with only the transform
argument.
Example
❌ Bad:
class SomeWidget {
Widget build() {
// LINT: Prefer 'Transform' over 'Container' with only the 'transform' argument.
Container(transform: Matrix4.skewY(0.3)..rotateZ(-math.pi / 12.0), child: Widget());
}
}
✅ Good:
class SomeWidget {
Widget build() {
Transform(
transform: Matrix4.skewY(0.3)..rotateZ(-math.pi / 12.0),
child: Widget(),
);
Container(
transform: Matrix4.skewY(0.3)..rotateZ(-math.pi / 12.0),
alignment: Alignment.topRight,
child: Widget(),
);
}
}