getMe method Null safety
- UserDataModel userDataNotifier
Static Method getting the connected User
Checks if the Installed Flow is created. If not it creates it and fetch the user's data, either it's already created it just fetch the user's data.
Implementation
static getMe(UserDataModel userDataNotifier) async {
ApiLauncher redditApi = ApiLauncher();
UserData userDatas = UserData();
Redditor? retrievedUser;
if (redditApi.isFlowCreated() == false)
await redditApi.createRedditFlow();
retrievedUser = await redditApi.redditApi.user.me();
if (retrievedUser == null)
return (null);
userDatas = UserData.fromMap(retrievedUser);
userDataNotifier.addUserDatas(userDatas);
}