Flutter:如何检查DataSnapshot是否为空?

时间:2018-08-24 05:24:11

标签: flutter

我正在Flutter中创建一个chat app。我想在从ProgressBar加载聊天消息时添加一个Firebase。为此,我需要检查DataSnapshot是否为空。如何检查?

我当前的代码:

           child: new FirebaseAnimatedList(
              query: reference,
              padding: const EdgeInsets.all(8.0),
              reverse: true,
              sort: (a, b) => b.key.compareTo(a.key),
              //comparing timestamp of messages to check which one would appear first
              itemBuilder: (_, DataSnapshot messageSnapshot,
                  Animation<double> animation, int index) {
                return new ChatMessageListItem(
                  messageSnapshot: messageSnapshot,
                  animation: animation,
                );
              },
            ),
          ),

0 个答案:

没有答案