build method

  1. @override
Widget build(
  1. BuildContext context
)
override

👷‍♂️🌟 Build Surface

Implementation

@override
Widget build(BuildContext context) {
  assert(
      ((filter.filteredLayers == Filter.TRILAYER)
              ? (filter.renderedRadiusBase >= _BLUR_MINIMUM &&
                  filter.renderedRadiusMaterial >= _BLUR_MINIMUM)
              : true) ||
          ((filter.filteredLayers == Filter.INNER_BILAYER)
              ? (filter.renderedRadiusMaterial >= _BLUR_MINIMUM)
              : true) ||
          ((filter.filteredLayers == Filter.BASE_AND_CHILD)
              ? (filter.renderedRadiusBase >= _BLUR_MINIMUM)
              : true) ||
          ((filter.filteredLayers == Filter.BASE_AND_MATERIAL)
              ? (filter.renderedRadiusBase >= _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 InteractiveInkFeatureFactory _splashFactory =
      tapSpec.useThemeSplashFactory
          ? Theme.of(context).splashFactory
          : tapSpec.splashFactory ?? BouncyBall.splashFactory;

  final SurfaceShape shapeBase = SurfaceShape(
    cornerSpec: shape.baseCornersOr,
    borderRadius: shape.radius,
    border: shape.baseBorderOr ?? BorderSide.none,
  ).scale(shape.shapeScaleBase);

  final SurfaceShape shapeMaterial = SurfaceShape(
    cornerSpec: shape.corners,
    borderRadius: 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, splashFactory: _splashFactory),
    ),
  );

  // ! ---
  // * 🌟🐚 [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),
  );
}