toWidget method

  1. @override
Widget toWidget(
  1. RenderContext context
)
override

Implementation

@override
Widget toWidget(RenderContext context) {
  final double _width = width ?? (height ?? 150) * 2;
  final double _height = height ?? (width ?? 300) / 2;
  return AspectRatio(
    aspectRatio: _width / _height,
    child: Container(
      key: AnchorKey.of(context.parser.key, this),
      child: Chewie(
        controller: ChewieController(
          videoPlayerController: VideoPlayerController.network(
            src.first ?? "",
          ),
          placeholder: poster != null
              ? Image.network(poster!)
              : Container(color: Colors.black),
          autoPlay: autoplay,
          looping: loop,
          showControls: showControls,
          autoInitialize: true,
          aspectRatio: _width / _height,
        ),
      ),
    ),
  );
}