Flutter video_player 无法显示视频

Flutter video_player can not show the video

我使用 video_player 0.10.4+1 但是当我 运行 应用程序时我的视频无法播放它是透明的。像这样。 here is the problem 这是我用于显示视频的代码。

class VideoApp extends StatefulWidget {
@override
_VideoAppState createState() => _VideoAppState();
}

class _VideoAppState extends State<VideoApp> {
 VideoPlayerController _controller;

 @override
 void initState() {
  super.initState();
  _controller = VideoPlayerController.asset(
      'assets/vi1.mp4')
    ..initialize().then((_) {
    setState(() {});
  });
 }

@override
Widget build(BuildContext context) {
return MaterialApp(
  title: 'Video Demo',
  home: Scaffold(
    body: Center(
      child: _controller.value.initialized
          ? AspectRatio(
              aspectRatio: _controller.value.aspectRatio,
              child: VideoPlayer(_controller),
            )
          : Container(),
    ),
    floatingActionButton: FloatingActionButton(
      onPressed: () {
        setState(() {
          _controller.value.isPlaying
              ? _controller.pause()
              : _controller.play();
        });
      },
      child: Icon(
        _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
      ),
    ),
  ),
);
}

@override
void dispose() {
 super.dispose();
 _controller.dispose();
}
}

这就是我导入上述文件的方式。

class ActivityClip extends StatefulWidget {
ActivityClip({Key key, this.title}) : super(key: key);

final String title;

@override
_ActivityState createState() => _ActivityState();
}

class _ActivityState extends State<ActivityClip> {
final List<String> numbers = [
'Soft Music',
'Meditation',
'Pray',
'Breathing',
'Relex'
 ];
@override
Widget build(BuildContext context) {
return Container(
    margin: const EdgeInsets.only(right: 10, left: 10, top: 350),
    height: MediaQuery.of(context).size.height * 0.3,
    child: ListView.builder(
        scrollDirection: Axis.horizontal,
        itemCount: numbers.length,
        itemBuilder: (context, index) {
          return Container(
              width: 200,
              margin: const EdgeInsets.only(right: 10),
              child: RaisedButton(
                color: Colors.brown,
                child: Container(
                  child: Center(
                      child: Text(
                    numbers[index].toString(),
                    style: TextStyle(color: Colors.white, fontSize: 30.0),
                  )),
                ),
                onPressed: () {
                  _showMaterialDialog();
                 //activityVideo(context);
                },
              ));
        }));  
       }

_showMaterialDialog() {
showDialog(
    context: context,
    builder: (_) => new AlertDialog(
          title: new Text("Material Dialog"),
          content: Container(
    height: 400,
     width: 300,
          child: VideoApp()),
          actions: <Widget>[
            FlatButton(
              child: Text('Close me!'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            )
          ],
        ));
       }


     }

我不确定这个代码是错误的还是来自我的设备,因为根本就没有错误。
谢谢大家的建议。

添加任何包或资产后,始终建议进行 flutter clean 和 flutter 运行。