GlassContainer constructor
GlassContainer({
- Key? key,
- required double height,
- required double width,
- AlignmentGeometry? alignment,
- Matrix4? transform,
- AlignmentGeometry? transformAlignment,
- EdgeInsetsGeometry? padding,
- EdgeInsetsGeometry? margin,
- Color? color,
- Gradient? gradient,
- BorderRadius? borderRadius,
- double? borderWidth,
- Color? borderColor,
- Gradient? borderGradient,
- double? blur,
- bool? isFrostedGlass,
- double? frostedOpacity,
- double? elevation,
- Color? shadowColor,
- BoxShape shape = BoxShape.rectangle,
- Widget? child,
Creates a widget by combining common painting, sizing, and positioning widgets to implement Glass Morphism.
- The arguments
height
andwidth
must not benull
. - Both color and gradient cannot be
null
. Same goes for borderColor and borderGradient. Preference is given to gradient during painting. - The
borderRadius
argument must benull
if theshape
isBoxShape.Circle
- By default
borderWidth
is1.0
,isFrosted
is set tofalse
andblur
value is set to12.0
. - If the shape is BoxShape.circle then height is used as the diameter.
The shape
argument must not be null
.
Implementation
GlassContainer({
Key? key,
required this.height,
required this.width,
this.alignment,
this.transform,
this.transformAlignment,
this.padding,
this.margin,
this.color,
this.gradient,
BorderRadius? borderRadius,
double? borderWidth,
this.borderColor,
this.borderGradient,
double? blur,
bool? isFrostedGlass,
double? frostedOpacity,
double? elevation,
Color? shadowColor,
BoxShape shape = BoxShape.rectangle,
this.child,
}) : borderWidth = borderWidth ?? kBorderWidth,
blur = blur ?? kBlur,
isFrostedGlass = isFrostedGlass ?? kIsFrosted,
frostedOpacity = frostedOpacity ?? kFrostedOpacity,
elevation = elevation ?? kElevation,
shadowColor = shadowColor ?? kShadowColor,
shape = shape,
borderRadius = shape == BoxShape.rectangle
? (borderRadius ?? kBorderRadius)
: null,
assert(color != null || gradient != null,
'Both color and gradient cannot be null\n'),
assert(borderColor != null || borderGradient != null,
'Both borderColor and borderGradient cannot be null\n'),
assert(shape != BoxShape.circle || borderRadius == null,
'The [borderRadius] needs to be null if the shape is [BoxShape.circle]\n'),
assert(kIsWeb != true || borderColor != null,
'borderColor cannot be null when runing on the Web\n'),
super(key: key);