GlassContainer class

A widget that combines common painting, sizing and positioning widgets to implement Glass Morphism.

A GlassContainer surrounds the child in a Container with necessary decoration properties like color, gradient, borderRadius and shape. Preference is given to gradient and borderGradient during painting.

GlassContainer paints border using CustomPaint with RectBorderPainter or CircleBorderPainter depending on the box shape.

BackdropFilter, frosted layer and container are stacked and clipped using ClipOval or ClipRRect to implement the Glass Effect

Inheritance

Constructors

GlassContainer({Key? key, Widget? child, double? width, Color? color, double? height, EdgeInsetsGeometry? margin, EdgeInsetsGeometry? padding, double? blur, Gradient? gradient, AlignmentGeometry? alignment, List<BoxShadow>? boxShadow, Matrix4? transform, Color? borderColor, double? elevation, Color? shadowColor, double? borderWidth, Gradient? borderGradient, bool? isFrostedGlass, double? frostedOpacity, AlignmentGeometry? transformAlignment, BorderRadius? borderRadius, BoxShape shape = BoxShape.rectangle})
Creates a widget by combining common painting, sizing, and positioning widgets to implement Glass Morphism.
GlassContainer.clearGlass({Key? key, double? height, double? width, AlignmentGeometry? alignment, Matrix4? transform, AlignmentGeometry? transformAlignment, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, Gradient? gradient, Color? color, BorderRadius? borderRadius, double? borderWidth, Gradient? borderGradient, Color? borderColor, double? blur, double? elevation, Color? shadowColor, BoxShape shape = BoxShape.rectangle, Widget? child, List<BoxShadow>? boxShadow})
Creates a widget that extends GlassContainer to implement a clear glass effect. Its a default implementation of the effect with editable decorations
GlassContainer.frostedGlass({Key? key, double? height, double? width, AlignmentGeometry? alignment, Matrix4? transform, AlignmentGeometry? transformAlignment, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, Gradient? gradient, Color? color, BorderRadius? borderRadius, double? borderWidth, Gradient? borderGradient, Color? borderColor, double? blur, double? elevation, Color? shadowColor, BoxShape shape = BoxShape.rectangle, double? frostedOpacity, Widget? child, List<BoxShadow>? boxShadow})
Creates a widget that extends GlassContainer to implement a frosted glass effect. Its a default implementation of the effect with editable decorations

Properties

alignment AlignmentGeometry?
Align the child within the GlassContainer.
final
blur double
The value of sigmaX and sigmaY properties of Gaussian Blur. In simple words its the extent to which the backdrop of GlassContainer is blurred
final
borderColor Color?
The color to fill in the border
final
borderGradient Gradient?
A gradient to use when painting the border
final
borderRadius BorderRadius?
If non-null, the corners of this box are rounded by this BorderRadius.
final
borderWidth double
The strokeWidth of the border
final
boxShadow List<BoxShadow>?
A list of shadows cast by this container behind it.
final
child Widget?
The child contained by the GlassContainer.
final
color Color?
The color to fill in the background of the box.
final
frostedOpacity double
Opacity value of the frosted layer. Specifically its the opacity of the white-noise image used for the effect.
final
gradient Gradient?
A gradient to use when filling the box.
final
hashCode int
The hash code for this object.
no setterinherited
height double?
The height of the GlassContainer
final
isFrostedGlass bool
Whether the GlassContainer will have frosted effect or not.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
margin EdgeInsetsGeometry?
Empty space to surround the GlassContainer's decoration and child.
final
padding EdgeInsetsGeometry?
Empty space to inscribe inside the GlassContainer. The child, if any, is placed inside this padding.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shape BoxShape
The shape to fill the background color, gradient into and to cast as the shadow. The heigth is used as the diameter of the circle
final
transform Matrix4?
The transformation matrix to apply before painting the GlassContainer.
final
transformAlignment AlignmentGeometry?
The alignment of the origin, relative to the size of the GlassContainer, if transform is specified.
final
width double?
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
getHeight([BoxConstraints? constraints]) double?
getWidth([BoxConstraints? constraints]) double?
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited