buildCaptureButton method

Widget buildCaptureButton(
  1. BuildContext context,
  2. BoxConstraints constraints
)

The shooting button. 拍照按钮

Implementation

Widget buildCaptureButton(BuildContext context, BoxConstraints constraints) {
  if (!isCaptureButtonTapDown &&
      (innerController?.value.isRecordingVideo ?? false)) {
    return const SizedBox.shrink();
  }
  const size = Size.square(82.0);
  return MergeSemantics(
    child: Semantics(
      label: textDelegate.sActionShootingButtonTooltip,
      onTap: onTap,
      onTapHint: onTapHint,
      onLongPress: onLongPress,
      onLongPressHint: onLongPressHint,
      child: Listener(
        behavior: HitTestBehavior.opaque,
        onPointerUp: onPointerUp,
        onPointerMove: onPointerMove(constraints),
        child: GestureDetector(
          onTap: onTap,
          onLongPress: onLongPress,
          onTapDown: (_) => safeSetState(() => isCaptureButtonTapDown = true),
          onTapUp: (_) => safeSetState(() => isCaptureButtonTapDown = false),
          onTapCancel: () =>
              safeSetState(() => isCaptureButtonTapDown = false),
          onLongPressStart: (_) =>
              safeSetState(() => isCaptureButtonTapDown = true),
          onLongPressEnd: (_) =>
              safeSetState(() => isCaptureButtonTapDown = false),
          onLongPressCancel: () =>
              safeSetState(() => isCaptureButtonTapDown = false),
          child: SizedBox.fromSize(
            size: size,
            child: Stack(
              fit: StackFit.expand,
              children: [
                AnimatedContainer(
                  duration: const Duration(microseconds: 100),
                  padding: EdgeInsets.all(isCaptureButtonTapDown ? 16 : 8),
                  decoration: BoxDecoration(
                    border: Border.all(
                      color: Colors.white,
                      strokeAlign: BorderSide.strokeAlignCenter,
                      width: 2,
                    ),
                    shape: BoxShape.circle,
                  ),
                  child: const DecoratedBox(
                    decoration: BoxDecoration(
                      color: Colors.white,
                      shape: BoxShape.circle,
                    ),
                  ),
                ),
                if (shouldCaptureButtonDisplay)
                  RotatedBox(
                    quarterTurns:
                        !enableScaledPreview ? cameraQuarterTurns : 0,
                    child: CameraProgressButton(
                      isAnimating:
                          isCaptureButtonTapDown && isShootingButtonAnimate,
                      duration: pickerConfig.maximumRecordingDuration!,
                      size: size,
                      ringsColor: theme.indicatorColor,
                      ringsWidth: 3,
                    ),
                  ),
              ],
            ),
          ),
        ),
      ),
    ),
  );
}