简体   繁体   中英

The method 'toDate' was called on null. Receiver: null Tried calling: toDate()

Container(
                  padding:
                      const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
                  alignment: Alignment.bottomRight,
                  child: Text(
                    DateFormat('hh:mm a').format(map['time'].toDate()) ,
                    style: const TextStyle(fontSize: 12),))

I'm showing the message date from firebase, when i send message to some one in the chat screen a red colored error displays first after the date is showing, how i can avoid this?

I guess your map is async, and you are not waiting for it. put an async where you are fetching the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM