GlassGroup class Composition
Draws every GlassSurface below it as one fused shape.
The analogue of SwiftUI's GlassEffectContainer, and spacing means what
its does: two surfaces closer than this at their nearest edges grow a bridge
between them. Zero is a legitimate declaration and not a disabled feature —
it says "share the capture, keep the silhouettes", which is the batch
without the blend.
A group holds the glass, not the page. It paints the fused shape and then its subtree, so everything inside it lands on top of the glass — which is what a panel's own label wants and what the content behind it does not. Put the background beside the group, not in it.
Stack(
children: <Widget>[
Positioned.fill(child: page), // behind the glass
Positioned.fill(
child: GlassGroup( // the glass, and only the glass
spacing: 12,
child: Stack(children: <Widget>[fab, toolbar]),
),
),
],
)
The finish is the group's, not each member's: one draw has one set of optics, so a member that names its own finish is declaring something the fused picture cannot express. Reported in debug, once, and then ignored.
A group costs fragments. One draw of N shapes evaluates every shape at every fragment, so each declared shape adds about 0.030 cycles per device pixel on Adreno 830 to every pixel the group covers — roughly half of what a lone glass fragment costs — and twelve make the fragment about six times a single surface's (same sign on Xclipse 920). The group draws tiles (debugGlassFusedSplit) to cover as little as it can: twelve grouped panels then cost 1.70x a stock Material card when clustered and 1.65x when scattered, on Adreno 830. On the M2 iPad Pro, in GPU time, twelve clustered panels grouped cost 1.18-1.21x the same twelve ungrouped.
So declare a group for the picture: put in the surfaces that should look merged and leave the rest out.
spacing zero is not the cheap way to have a group. It is the other declaration — one draw, one shared capture, every member keeping its own silhouette — and it costs 2.34x an ungrouped screen's addition where a spacing of 8 costs 3.05x (Adreno 830). The difference between the two spacings is area and nothing else: the fragment costs the same to within 0.4% either way. The cheap thing is not grouping.
See also:
- GlassUnion, which solves for the spacing that makes one piece.
- GlassMorph, a lone glass that borrows a group while it moves.
- GlassAbove, for glass that stands on other glass rather than beside it.
- kMaxFusedShapes, the most one draw carries.
- Groups on the site.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GlassGroup
Constructors
- GlassGroup({required Widget child, double spacing = 0, GlassFinish? finish, bool labelled = true, Key? key})
-
Fuses the GlassSurfaces in
childthat come withinspacingof each other.const
Properties
- child → Widget
-
The subtree whose surfaces are the members. Painted over the fused glass.
final
- finish → GlassFinish?
-
The optics for the whole group. Null takes the host's.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- labelled → bool
-
Whether labels are drawn over the group's glass; false for blobs and
drops, which then keep their finish. See GlassSurface.labelled.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spacing → double
-
The edge-to-edge distance at which two members fuse, in logical pixels.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< GlassGroup> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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.
inherited
-
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, int wrapWidth = 65}) → 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