flet-dev / examples

Flet sample applications
MIT License
457 stars 189 forks source link

optimised 'get_initials' function for main chat #101

Closed vikrant500 closed 10 months ago

vikrant500 commented 10 months ago

i tried running the chat.py tutorial code provided on github however it just didnt work no matter what i did due to an error with the browser itself and not the code as i was not getting a username popup. In order to identify the error quickly and to make sure the code works perfectly fine, i changed the get_initials function by adding an if-else statement to it for cases where the user does not exist. This helps in letting the user know that the code works just fine and that there is no problem with the code but with the browser or some other problem.

def get_initials(self, user_name: str):
        if user_name:
            return user_name[:1].capitalize()
        else:
            return "Unknown"  # or any default value you prefer

here is the updated function in chat.py

CLAassistant commented 10 months ago

CLA assistant check)
All committers have signed the CLA.