我会分享一些在网上找不到,或者遇到问题并解决的事情。
最近在调研Flutter视频播放,在横屏切换到竖屏的时候遇到了点问题。代码如下:
class PortraitPage extends StatefulWidget {
const PortraitPage({Key? key}) : super(key: key);
@override
_PortraitPageState createState() => _PortraitPageState();
}
class _PortraitPageState extends State<PortraitPage> {
VideoPlayerController? controller;
@override
void initState() {
super.initState();
controller = VideoPlayerController.network(
"https://cdn-resource.ekwing.com/acpf/data/upload/expand/2017/08/29/59a53da773e00.mp4")
..setLooping(true)
..initialize().then((_) {
controller!.play();
});
}
@override
void dispose() {
controller!.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Column(
children: [
AspectRatio