How should I add usename in chatroom?

I made a chat app using cloudDB . at the first screen it asks you your name and then switches to chat room. I want to make it like if somebody joined the chat . the username they entered in previous screen, become their username in the chatroom. but I can't use the same variable for two screens. what should I do?

Save the username in the TinyDB, and retrieve it when you needed, even in another screen.

When send chatting message, make the data like this
{'sender': your name here,
'message': your message here,
'receiver': receiver }
Using Dictionary.

2 Likes

Or just pop-up a Notifier to collect the name, then only one Screen is used.