build method

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

Override this method to build widgets that depend on the state of the listenable (e.g., the current value of the animation).

Implementation

@override
Widget build(BuildContext context) {
  return LayoutBuilder(
    builder: (context, constrains) {
      final scanningGradientHeight = constrains.maxHeight * scanningHeightOffset;
      final animation = listenable as Animation<double>;
      final value = animation.value;
      final scorePosition = (value * constrains.maxHeight * 2) - (constrains.maxHeight);

      final color = scanningColor ?? Colors.blue;

      return Stack(
        children: [
          Container(
            height: scanningGradientHeight,
            transform: Matrix4.translationValues(0, scorePosition, 0),
            decoration: BoxDecoration(
              gradient: LinearGradient(
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
                stops: const [
                  0.0,
                  0.2,
                  0.9,
                  0.95,
                  1,
                ],
                colors: [
                  color.withOpacity(0.05),
                  color.withOpacity(0.1),
                  color.withOpacity(0.4),
                  color,
                  color,
                ],
              ),
            ),
          ),
        ],
      );
    },
  );
}