秉承着看得懂就看看不懂就问的原则,直接上代码
import 'package:chewie/chewie.dart';
import 'package:connectivity/connectivity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:midou_ee/mall/mall_router.dart';
import 'package:midou_ee/routers/navigator_util.dart';
import 'package:video_player/video_player.dart';
class GoodVideoWidget extends StatefulWidget {
final String video;
GoodVideoWidget({Key key, this.video}) : super(key: key);
@override
_GoodVideoWidgetState createState() => _GoodVideoWidgetState();
}
class _GoodVideoWidgetState extends State<GoodVideoWidget> {
Widget playerWidget;
VideoPlayerController _controller;
// bool _isPlaying = false;
String url = '';
@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(widget.video)
..initialize().then((_) {
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Container(
height: 400.0,
color: Colors.grey,
child:_controller.value.initialized? Chewie(
controller: ChewieController(
videoPlayerController: _controller,
aspectRatio: _controller.value.aspectRatio,
autoPlay: false,
looping: false,
),
):SizedBox(),
);
}
}