Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从firebase获取我的数据快照?_Firebase_Flutter_Google Cloud Firestore - Fatal编程技术网

如何从firebase获取我的数据快照?

如何从firebase获取我的数据快照?,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我正在尝试播放视频。为此,我将数据保存到firebase。当用户点击视频时,我想用全屏方式显示视频。保存到firebase的操作已经完成。现在我试着给我的页面一些显示视频的数据。 我就是这样做的 class VideoPage2new extends StatefulWidget { static const route = '/Video2'; final String id ; const VideoPage2new({Key key, this.id}) : super(ke

我正在尝试播放视频。为此,我将数据保存到firebase。当用户点击视频时,我想用全屏方式显示视频。保存到firebase的操作已经完成。现在我试着给我的页面一些显示视频的数据。 我就是这样做的

class VideoPage2new extends StatefulWidget {
  static const route = '/Video2';
  final String id ;

  const VideoPage2new({Key key, this.id}) : super(key: key);

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

class _VideoPage2newState extends State<VideoPage2new> {
  Stream mystreamofallvideos;
    mystreamofallvideos =    FirebaseFirestore.instance.collection('videos').doc(widget.id).snapshots()
---- -- - - -

  @override
  Widget build(BuildContext context) {
    var size = MediaQuery.of(context).size;
    return Scaffold(
      body: StreamBuilder(
          stream: mystreamofallvideos,
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              return PageView.builder(
                  itemCount: snapshot.data.docs.length,
                  controller:
                      PageController(initialPage: 0, viewportFraction: 1),
                  scrollDirection: Axis.vertical,
                  itemBuilder: (context, index) {
                    DocumentSnapshot videos = snapshot.data.docs[index];
                    return Stack(
                      
                      children: [
                      Videoplayeritem(videos.data()['videourl']),
                - -- -
所以在点击功能中,我想给视频页面2当前的视频。我在onTap函数中打印,它等于我的firebase对象。但它看起来不像Videoplayeritem获得正确的数据
这是firebase中的外观

请尝试:
id:video.data()['id',
。我不确定您为什么要使用
['videourl']
,我在firebase中看不到它。在视频中,url实际上是相同的值。它不工作我将视频0更改为视频的id也许我应该使用视频的id而不是id属性调用此视频?如果是的话,我怎么称呼它?。如果你看我的帖子,我在mystreamofallvideos变量中尝试了它
  Future myVideos;

getalldata() async {
   String myID= FirebaseAuth.instance.currentUser.uid;
    myVideos = FirebaseFirestore.instance
        .collection('videos')
        .where('uid', isEqualTo: myID)
        .get();

 FutureBuilder(
                       future: myVideos,
                        builder: ( context, snapshot) {
                       if (snapshot.connectionState == ConnectionState.waiting) {
                                 return Center(child: CircularProgressIndicator());
                                  }
                                   if(videos>0){
                           return StaggeredGridView.countBuilder(
                            itemCount: snapshot.data.docs.length,
                            itemBuilder: (context, index) {
                              DocumentSnapshot video =
                             snapshot.data.docs[index];
                              return InkWell(
                                onTap: () {
                                 
                                   print(video.data()['videourl']);
                                  return VideoPage2new(
                                 id: video.data()['videourl'],