buildCaptureButton method

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

The shooting button. 拍照按钮

Implementation

Widget buildCaptureButton(BuildContext context, BoxConstraints constraints) {
  const Size outerSize = Size.square(115);
  const Size innerSize = Size.square(82);
  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,
          child: SizedBox.fromSize(
            size: outerSize,
            child: Stack(
              alignment: Alignment.center,
              children: <Widget>[
                AnimatedContainer(
                  duration: kThemeChangeDuration,
                  width: isShootingButtonAnimate
                      ? outerSize.width
                      : innerSize.width,
                  height: isShootingButtonAnimate
                      ? outerSize.height
                      : innerSize.height,
                  padding: EdgeInsets.all(isShootingButtonAnimate ? 41 : 11),
                  decoration: BoxDecoration(
                    color: Theme.of(context).canvasColor.withOpacity(0.85),
                    shape: BoxShape.circle,
                  ),
                  child: const DecoratedBox(
                    decoration: BoxDecoration(
                      color: Colors.white,
                      shape: BoxShape.circle,
                    ),
                  ),
                ),
                if (shouldCaptureButtonDisplay)
                  RotatedBox(
                    quarterTurns:
                        !enableScaledPreview ? cameraQuarterTurns : 0,
                    child: CameraProgressButton(
                      isAnimating: isShootingButtonAnimate,
                      isBusy: isControllerBusy,
                      duration: pickerConfig.maximumRecordingDuration!,
                      size: outerSize,
                      ringsColor: theme.indicatorColor,
                      ringsWidth: 3,
                    ),
                  ),
              ],
            ),
          ),
        ),
      ),
    ),
  );
}