render method

  1. @override
Widget render(
  1. NudgeVideo node,
  2. BuildContext context
)
override

Implementation

@override
Widget render(NudgeVideo node, BuildContext context) {
  final url = VariableScopeProvider.of(context).resolve(node.url);
  if (url.isEmpty) {
    return NudgePlaceholder(label: 'No video URL', height: node.height);
  }
  final radius = node.box.borderRadius > 0
      ? BorderRadius.circular(node.box.borderRadius)
      : BorderRadius.zero;

  // A fixed-height, full-width black box (matching the dashboard preview). The
  // player keeps its own aspect ratio and is centered; any letterbox is black,
  // so it reads as one clean video box rather than white gaps around the frame.
  return ClipRRect(
    borderRadius: radius,
    child: Container(
      height: node.height,
      width: double.infinity,
      color: const Color(0xFF000000),
      alignment: Alignment.center,
      // `muted` is parsed but InternalVideoPlayer has no volume control yet;
      // chewie plays with its default volume.
      child: InternalVideoPlayer(
        videoUrl: url,
        autoPlay: node.autoplay,
        looping: node.loop,
        showControls: node.showControls,
      ),
    ),
  );
}