build method Null safety

  1. @override
dynamic build(
  1. dynamic context
)

Implementation

@override
Widget build(BuildContext context) {
  final ContinuousScanModel model = context.watch<ContinuousScanModel>();
  return LayoutBuilder(
    builder: (
      BuildContext context,
      BoxConstraints constraints,
    ) {
      final Size screenSize = MediaQuery.of(context).size;

      final double carouselHeight =
          constraints.maxHeight * ScannerOverlay.carouselHeightPct;
      final double buttonRowHeight = model.getBarcodes().isNotEmpty
          ? ScannerOverlay.buttonRowHeightPx
          : 0;
      final double availableScanHeight =
          constraints.maxHeight - carouselHeight - buttonRowHeight;

      final Size scannerContainerSize = Size(
        screenSize.width,
        availableScanHeight - carouselBottomPadding,
      );

      return Container(
        color: Colors.black,
        child: Stack(
          children: <Widget>[
            //Scanner
            if (backgroundChild != null)
              // Force the child to take the full space, otherwise the
              // [VisibilityDetector] may return incorrect results
              SmoothRevealAnimation(
                delay: 400,
                startOffset: Offset.zero,
                animationCurve: Curves.easeInOutBack,
                child: SizedBox.expand(
                  child: backgroundChild,
                ),
              ),
            // Scanning area overlay
            SmoothRevealAnimation(
              delay: 400,
              startOffset: const Offset(0.0, 0.1),
              animationCurve: Curves.easeInOutBack,
              child: ConstrainedBox(
                constraints: BoxConstraints.tight(
                  scannerContainerSize,
                ),
                child: Center(child: topChild),
              ),
            ),
            // Product carousel
            SmoothRevealAnimation(
              delay: 400,
              startOffset: const Offset(0.0, -0.1),
              animationCurve: Curves.easeInOutBack,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  const SafeArea(top: true, child: ScanHeader()),
                  const Spacer(),
                  Padding(
                    padding:
                        const EdgeInsets.only(bottom: carouselBottomPadding),
                    child: SmoothProductCarousel(
                      containSearchCard: true,
                      height: carouselHeight,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      );
    },
  );
}