opacity method
Applies the specified opacity to the widget.
Creates an Opacity widget that makes the child partially transparent. This is the base method that other opacity methods in this extension use internally.
The opacity value should be between 0.0 (completely transparent) and 1.0 (completely opaque). Values outside this range will be clamped.
Parameters:
opacity: The opacity level (0.0 to 1.0).alwaysIncludeSemantics: Whether to include semantics information even when the widget is completely transparent. Defaults to false.
Returns an Opacity widget containing this widget as its child.
Example:
Container(
width: 100,
height: 100,
color: Colors.blue,
).opacity(0.7); // 70% opacity
Implementation
Opacity opacity(double opacity, {bool alwaysIncludeSemantics = false}) {
assert(opacity >= 0.0 && opacity <= 1.0,
'Opacity must be between 0.0 and 1.0');
return Opacity(
opacity: opacity,
alwaysIncludeSemantics: alwaysIncludeSemantics,
child: this,
);
}