asGlass method Null safety
- {double blurX = 4.0,
- double blurY = 4.0,
- Color tintColor = Colors.white,
- bool frosted = true,
- BorderRadius? clipBorderRadius = BorderRadius.zero,
- Clip clipBehaviour = Clip.antiAlias,
- TileMode tileMode = TileMode.clamp,
- CustomClipper<
RRect> ? clipper}
.asGlass(): Converts the calling widget into a glass widget.
Parameters:
blurX
: Amount of blur in the direction of the X axis.blurY
: Amount of blur in the direction of the Y axis.tintColor
: Tint color for the glass (defaults to Colors.white)frosted
: Whether this glass should be frosted or not (defaults to true)clipBorderRadius
: The border radius of the rounded corners. Values are clamped so that horizontal and vertical radii sums do not exceed width/height. This value is ignored ifclipper
is non-null.clipBehaviour
: Defaults toClip.antiAlias
.tileMode
: Defines what happens at the edge of a gradient or the sampling of a source image in anImageFilter
.clipper
: If non-null, determines which clip to use.
Implementation
ClipRRect asGlass({
double blurX = 4.0,
double blurY = 4.0,
Color tintColor = Colors.white,
bool frosted = true,
BorderRadius? clipBorderRadius = BorderRadius.zero,
Clip clipBehaviour = Clip.antiAlias,
TileMode tileMode = TileMode.clamp,
CustomClipper<RRect>? clipper,
}) {
return ClipRRect(
clipper: clipper,
clipBehavior: clipBehaviour,
borderRadius: clipBorderRadius,
child: BackdropFilter(
filter: new ImageFilter.blur(
sigmaX: blurX,
sigmaY: blurY,
tileMode: tileMode,
),
child: Container(
decoration: BoxDecoration(
gradient: (tintColor != Colors.transparent)
? LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
tintColor.withOpacity(0.1),
tintColor.withOpacity(0.08),
],
)
: null,
image: frosted
? DecorationImage(
image: AssetImage('images/noise.png', package: 'glass'),
fit: BoxFit.cover,
)
: null,
),
child: this,
),
),
);
}