首页 > 解决方案 > 如何用uid调用另一个表属性?- 火地颤动

问题描述

我的问题类似于这个如何在 Firebase 中比较 UID 和另一个子键?

我正在尝试从该线程创建类似的代码,但它不起作用

这是我的火力基地https://imgur.com/ZpU8ODO

StreamBuilder(
        stream: FirebaseDatabase.instance
            .reference()
            .child("questions")
            .onValue,
        builder: (BuildContext context, AsyncSnapshot<Event> snapshot) {
          if (snapshot.hasData) {
            Map<dynamic, dynamic> map = snapshot.data.snapshot.value;
            return GridView.builder(
              gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 1,
                childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 4),
                mainAxisSpacing: 16.0,
              ),
              itemCount: map.values.toList().length,
              padding: EdgeInsets.only(left: 16, right: 16, top: 16),
              itemBuilder: (BuildContext context, int index) {
                return Container(
                  color: bgSecondaryColor,
                child: Column(
                  children: <Widget>[
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Flexible(
                          child: Text(
                            parse(parse(map.values.toList()[index]["question"]).body.text).documentElement.text,
                          ),
                        ),
                        Container(
                          child: Column(
                            children: <Widget>[
                              CircleAvatar(
                                backgroundImage: NetworkImage('https://mdn.mozillademos.org/files/7693/catfront.png'),
                                backgroundColor: Colors.lightGreen,
                                radius: 24.0,
                              ),
                              Text(
                                //I want to call the "name" attribute in users here,
                              ),

                            ],
                          ),
                        ),
                      ],
                    ),

                  ],
                ),
                );
              },

对不起,我在颤振和火力方面都是新手。来自我的亲切问候。谢谢

标签: firebasefirebase-realtime-databaseflutterdart

解决方案


推荐阅读