Skip to main content

avoid-incorrect-image-opacity

added in: 1.19.0
🛠
Pro+

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
Opacity(
opacity: 1,
child: Image.asset('...'),
);

✅ Good:

Image.asset(
'...',
opacity: const AlwaysStoppedAnimation(0.5),
);