【发布时间】:2019-02-17 14:38:48
【问题描述】:
我很想在 ListView.builder 中创建一个视频播放器。我的视频存储在 Firestore 中。在 ListView.builder 中加载视频时没有问题,但是每当您向上和向下滚动页面时,我都会在红色框中收到错误消息:
一个 VideoPlayerController 在被释放后被使用。
I/flutter : 一旦你在 VideoPlayerController 上调用了 dispose(),它就不能再使用了。
Widget _modeApp(){
return new ListView.builder(
itemCount: dataApp.length,
itemBuilder: (context,i){
String _path = dataApp[i].url;
_controllers.add(new TextEditingController());
_focusNode.add(new FocusNode());
return new Card(
child: new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Container(
width: 50.0,
height: 50.0,
margin: const EdgeInsets.all(15.0),
decoration: new BoxDecoration(
border: new Border.all(color: Colors.black38),
shape: BoxShape.circle,
image: new DecorationImage(image: new NetworkImage(dataApp[i].aurl))
),
),
new Text(dataApp[i].name,style: new TextStyle(fontWeight: FontWeight.bold)),
],
),
new Chewie(
VideoPlayerController.network(_path),
aspectRatio: 3 / 2,
autoPlay: false,
looping: false,
),
new Container(
margin: const EdgeInsets.only(left: 12.0,top: 12.0),
child: new Row(
children: <Widget>[
new Icon(Icons.favorite_border,size: 27.0),
new Padding(padding: EdgeInsets.only(left: 15.0)),
new Icon(Icons.chat_bubble_outline,size: 27.0),
new Padding(padding: EdgeInsets.only(left: 15.0)),
new Icon(Icons.turned_in_not,size: 27.0),
],
),
),
new ListTile(
title: new Text(dataApp[i].text,style: new TextStyle(fontWeight: FontWeight.bold),),
subtitle: new Text(dataApp[i].time),
),
new ListTile(
leading: new Container(
width: 50.0,
height: 50.0,
decoration: new BoxDecoration(
border: new Border.all(color: Colors.black38),
shape: BoxShape.circle,
image: widget.accountEmail == null
? new DecorationImage(image: new NetworkImage("${widget.value.photoUrl}"))
: new DecorationImage(image: new NetworkImage("${widget.accountPhoto}")),
),
),
title: new EnsureVisibleWhenFocused(
focusNode: _focusNode[i],
child: new TextField(
focusNode: _focusNode[i],
controller: _controllers[i],
style: new TextStyle(
fontSize: 15.0,
color: Colors.black
),
decoration: new InputDecoration(
border: InputBorder.none,
hintText: "Add a comment...",
hintStyle: new TextStyle(color: Colors.grey),
),
),
),
trailing: new IconButton(
icon: new Icon(Icons.send, color: _controllers[i].text != "" ? Colors.blue : null), onPressed: _controllers[i].text != "" ? () => _showMessage(i) : null),
),
new Padding(
padding: EdgeInsets.only(top: 13.0)),
],
),
);}
);
}
【问题讨论】:
-
您最终找到解决方案了吗?
标签: flutter