【问题标题】:Arranging icons from cloud firestore in flutter在 Flutter 中排列来自 Cloud Firestore 的图标
【发布时间】:2021-05-10 03:27:06
【问题描述】:

我有一个 AlertDialog,其中包含来自云 Firestore 的图标。我正在努力更改图标的布局,使其看起来正常。 (1) 是目前正在展示的,(2) 是我想要实现的。

(1)

(2)

这是我的代码:

Widget _buildPopupDialog(BuildContext context) {
    return Scaffold(
        body: StreamBuilder(
            stream: FirebaseFirestore.instance.collection('icons').snapshots(),
            builder: (context, snapshot) {
              return new AlertDialog(
                content: SingleChildScrollView(
                  child: new Container(
                      height: 500,
                      width: 300,
                      child: new ListView(
                        children: snapshot.data.documents
                            .map<Widget>((DocumentSnapshot document) {
                          return new MoodButton(
                            iconData: (IconData(document.data()['ref'],
                                fontFamily: 'MaterialIcons')),
                            onTap: () => print("Mood"),
                          );
                        }).toList(),
                      )),
                ),
              );
            }));

任何帮助将不胜感激!

【问题讨论】:

    标签: flutter dart google-cloud-firestore


    【解决方案1】:

    您应该使用GridView 而不是ListView。将crossAxisCount 属性设置为3,你应该会得到你想要的结果。有疑问可以找GridView的文档here

    【讨论】:

      猜你喜欢
      • 2018-11-22
      • 2020-09-14
      • 2020-08-15
      • 2022-01-17
      • 2021-03-29
      • 2019-07-12
      • 2021-05-05
      • 2021-11-30
      • 2020-11-08
      相关资源
      最近更新 更多