builder method

  1. @override
Widget builder(
  1. BuildContext context,
  2. BoxConstraints constraints,
  3. Widget child
)
override

Called when the layout needs to be rebuilt.

Allows the behaviour to include new widgets between the background and the provided child. (ie. include a GestureDetector to make the background interactive.

Implementation

@override
Widget builder(
    BuildContext context, BoxConstraints constraints, Widget child) {
  double widgetX = 0.0, widgetY = 0.0;
  if (renderObject!.hasSize) {
    widgetX = size!.width / 2 * _childZ;
    widgetY = size!.height / 2 * _childZ;
  }

  return Opacity(
    opacity: (100 - _childZ) / 100,
    child: Transform(
      transform: Matrix4.identity()
        ..setEntry(3, 2, 1.0)
        ..translate(widgetX, widgetY, _childZ),
      child: super.builder(context, constraints, child),
    ),
  );
}