avoid-incorrect-image-opacity
preset: recommended
Warns when an Image
widget is wrapped into an Opacity
widget.
Passing a value for the opacity
parameter is much more efficient than using the Opacity
widget.
Example
❌ Bad:
// LINT: Avoid wrapping images into the 'Opacity' widget. Try passing the 'opacity' argument directly.
Opacity(
opacity: 1,
child: Image.asset('...'),
);
✅ Good:
Image.asset(
'...',
opacity: const AlwaysStoppedAnimation(0.5),
);