我需要在“ MovieDetail”类中获取链接变量,以便在“ void _detailDialog”中使用它,但是当我按下共享按钮时,该值为空。链接变量位于类“ VideoView”中
class MovieDetail extends StatefulWidget {
@override
_MovieDetailState createState() => _MovieDetailState();
}
class _MovieDetailState extends State<MovieDetail> {
final videoView = VideoView();
final moviesProvider = MoviesProvider();
final scrollController = ScrollController();
GlobalKey<ScaffoldState> _scaffoldkey = new GlobalKey<ScaffoldState>();
void _detailDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: new Text('Enviar a WebVideoCaster'),
content: new Text('(Necesitas descargar la app)'),
actions: <Widget>[
new FlatButton(
child: new Text("Enviar"),
onPressed: () {
Share.share(Cast.all(context, link: videoView.link));
},
)
],
);
});
}
}
class VideoView extends StatefulWidget {
final String link;
final bool progress;
VideoView(this.link, {this.progress = true});
@override
_VideoViewState createState() => _VideoViewState();
}
答案 0 :(得分:0)
在_MovieDetailState
类中创建VideoView实例时,只需传递链接即可。
final videoView = VideoView("your-link-goes-here");