我正在使用dio包将视频文件和表单数据发送到服务器,但是在我调用api时显示错误,而api没有调用:
错误:HttpException:内容大小超出了指定的contentLength。写入917730字节,而预期为915419。
RespondedVideos类扩展了StatefulWidget {
var slug; RespondedVideos({Key key,@ required this.slug}):super(key:key);
@override responseedVideosState createState()=> respondedVideosState();
}
class respondedVideosState extends State<RespondedVideos> {
VideoPlayerController _controller;
List data = new List();
var respondercookie;
String video_url = "";
@override
void initState() {
super.initState();
readCookie();
}
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Flexible(
flex: 1,
child:Container(
height: 100,
child: Card(
margin: EdgeInsets.fromLTRB(3.0, 60.0, 3.0, 0.0),
color: Colors.blueAccent,
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Text("Feedback: ")
],
),
Row(
children: <Widget>[
Text("Status: ")
//+data[position].name,style:TextStyle(color: Colors.blueAccent)
],
)
]
),
),
)
),
SizedBox(height: 10),
Flexible(
flex: 2,
child:Container(
height: 1000,
child: StreamBuilder(
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.tealAccent),
),
);
} else {
return ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
padding: EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int position) {
if(data[position]["source_url"] != null)
video_url = data[position]["source_url"];
_controller = VideoPlayerController.network(video_url
)
..initialize().then((_) {
setState(() {});
});
_controller.setVolume(30.0);
return new Container(
child: Center(
child: Card(
child: Container(
width: 230.0,
child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Stack(
children: <Widget>[
Container(
child: _controller.value.initialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: Container(),
),
Column(
children: <Widget>[
Padding(padding: new EdgeInsets.symmetric(
vertical: 80.0, horizontal: 160.0)),
RaisedButton(
color: Colors.transparent,
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying
? Icons.pause
: Icons.play_arrow,
color: Colors.blueAccent,
),
),
],
),
],
),
],
),
),
),
)
);
}
);
}
}
)
)
),
],
);
}