avoid-incorrect-image-opacity
- Group
- Correctness
- Path
lint/correctness/avoid-incorrect-image-opacity- Default
- Off, opt in
- Origin
- Falcon
- Domain
- flutter
- Rule
- 73 of 512
Flags Opacity directly wrapping a Flutter Image, including named constructors. Prefer Image.opacity (or image color blending) to compositing the whole widget.
Invalid
import 'package:flutter/widgets.dart';
import 'package:flutter/widgets.dart' as f;
typedef I = Image;
void callback() {}
void examples(Widget child, dynamic image, dynamic color, double size, String label) {
Opacity(opacity: .5, child: Image(image: image));
Opacity(opacity: .2, child: Image.asset("a"));
const Opacity(opacity: .5, child: Image());
f.Opacity(opacity: .5, child: f.Image.network("a"));
new Opacity(opacity: .5, child: I.asset("a"));
}void examples(Widget child, dynamic image, dynamic color, double size, String label) { Opacity(opacity: .5, child: Image(image: image)); Opacity(opacity: .5, child: Image(image: image)); Opacity(opacity: .2, child: Image.asset("a")); Opacity(opacity: .2, child: Image.asset("a")); const Opacity(opacity: .5, child: Image()); const Opacity(opacity: .5, child: Image()); f.Opacity(opacity: .5, child: f.Image.network("a")); f.Opacity(opacity: .5, child: f.Image.network("a")); new Opacity(opacity: .5, child: I.asset("a"));Valid
import 'package:flutter/widgets.dart';
import 'package:flutter/widgets.dart' as f;
typedef I = Image;
void callback() {}
void examples(Widget child, dynamic image, dynamic color, double size, String label) {
Opacity(opacity: .5, child: SizedBox());
Image(image: image, opacity: image);
Opacity(opacity: .5);
Opacity(opacity: .5, child: Container(child: Image()));
Opacity(opacity: .5, child: child);
}Configure avoid-incorrect-image-opacity
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"correctness": {
"avoid-incorrect-image-opacity": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/correctness/avoid-incorrect-image-opacity: <reason>More correctness rules
- avoid-inherited-widget-in-initstaterecommendedflutter
Avoid inherited-widget subscriptions during initState.
- avoid-instantiating-in-value-providerprovider
Value providers borrow existing instances; newly constructed values need create.
- avoid-late-contextrecommendedflutter
Avoid storing
BuildContextin late fields or reading it in late initializers. - avoid-missing-completer-stack-trace
Preserve error origins when calling SDK
Completer.completeError. - avoid-missing-controllerflutter
Require Flutter text fields to expose their updated value.
- avoid-missing-enum-constant-in-map
Require enum-keyed map literals to include every declared enum value.
- avoid-missing-interpolationrecommended
Flags missing interpolation around visible String variables or member accesses and calls.
- avoid-misused-hooksrecommendedflutter_hooks
Flags confirmed Flutter hooks called directly in non-hook Flutter widget builds.