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 const SizedBox.shrink();
  }
  final radius = node.box.borderRadius > 0
      ? BorderRadius.circular(node.box.borderRadius)
      : BorderRadius.zero;

  final player = Container(
    width: double.infinity,
    color: const Color(0xFF000000),
    alignment: Alignment.center,
    // The authored ratio sizes the outer frame below. Let the player keep the
    // source ratio so a mismatched frame letterboxes instead of stretching.
    child: InternalVideoPlayer(
      videoUrl: url,
      autoPlay: node.autoplay,
      looping: node.loop,
      showControls: node.showControls,
      muted: node.muted,
    ),
  );

  return ClipRRect(
    borderRadius: radius,
    child: node.aspectRatio > 0
        ? AspectRatio(aspectRatio: node.aspectRatio, child: player)
        : SizedBox(height: node.height, child: player),
  );
}