build method
Implementation
@override
Widget build(BuildContext context) {
assert(
((filter.filteredLayers == Filter.TRILAYER)
? (filter.literalRadiusBase >= _BLUR_MINIMUM &&
filter.literalRadiusMaterial >= _BLUR_MINIMUM)
: true) ||
((filter.filteredLayers == Filter.INNER_BILAYER)
? (filter.literalRadiusMaterial >= _BLUR_MINIMUM)
: true) ||
((filter.filteredLayers == Filter.BASE_AND_CHILD)
? (filter.literalRadiusBase >= _BLUR_MINIMUM)
: true) ||
((filter.filteredLayers == Filter.BASE_AND_MATERIAL)
? (filter.literalRadiusBase >= _BLUR_MINIMUM)
: true),
'[Surface] > Upper-layered filters will be negated if ancestor filters are enabled that have radius < 0.0003.\n'
'Increase blur radius of lower layer(s) or pass a different [Filter.filteredLayers].');
_fallbacks[SurfaceLayer.BASE] =
Theme.of(context).colorScheme.primary.withBlack(100).withOpacity(0.75);
_fallbacks[SurfaceLayer.MATERIAL] =
Theme.of(context).colorScheme.surface.withOpacity(0.5);
_fallbacks['HIGHLIGHT'] = Theme.of(context).highlightColor;
_fallbacks['SPLASH'] = Theme.of(context).splashColor;
final shapeBase = SurfaceShape(
cornerSpec: shape.baseCornersOr,
borderRadius:
shape.baseCorners?.radius ?? shape.corners.radius ?? shape.radius,
border: shape.baseBorderOr ?? BorderSide.none,
).scale(shape.shapeScaleBase);
final shapeMaterial = SurfaceShape(
cornerSpec: shape.corners,
borderRadius: shape.corners.radius ?? shape.radius,
border: shape.border ?? BorderSide.none,
).scale(shape.shapeScaleMaterial);
// ! ---
// * 🌟🧅 [innerMaterial] == 📚 [SurfaceLayer.MATERIAL]
// Material will be canvas for [child] and respond to touches.
final AnimatedContainer innerMaterial = AnimatedContainer(
duration: duration,
curve: curve,
decoration: _decorate(SurfaceLayer.MATERIAL, shapeMaterial),
child: Material(
color: Colors.transparent,
child: _wrapChild(shapeMaterial),
),
);
// ! ---
// * 🌟🐚 [baseContainer] == 📚 [SurfaceLayer.BASE]
final AnimatedContainer baseContainer = AnimatedContainer(
width: width,
height: height,
duration: duration,
curve: curve,
decoration: _decorate(SurfaceLayer.BASE, shapeBase),
margin: filter.extendBaseFilter ? margin : const EdgeInsets.all(0),
// 🔲 This "peek" is effectively the "border" of the Surface.
// Values generated at start of build() using 🔲 Peek.
padding: EdgeInsets.fromLTRB(
peek.peekLeft,
peek.peekTop,
peek.peekRight,
peek.peekBottom,
),
/// 🌟🧅 `innerMaterial` as descendent of 🌟🐚 `baseContainer`
child: _filter(
SurfaceLayer.MATERIAL,
shapeMaterial,
child: innerMaterial,
),
);
// ! ---
// * 📤🌟 Return [Surface]
return AnimatedPadding(
duration: duration,
curve: curve,
padding: (filter.extendBaseFilter) ? const EdgeInsets.all(0) : margin,
child: _filter(SurfaceLayer.BASE, shapeBase, child: baseContainer),
);
}