getCurrentUser method

Future<AppticsUser?> getCurrentUser()

Implementation

Future<AppticsUser?> getCurrentUser() async {
  AppticsUser? currentUser;
  final userInfoFileContent = await AppticsDataStore.getFileContents(FileType.userInfo);
  if (userInfoFileContent != null) {
    Map<String, dynamic> users = jsonDecode(userInfoFileContent);

    users.forEach((key, value) {
      final userProp = value as Map<String, dynamic>;
      if (userProp.containsKey("isActive") && userProp["isActive"] == true) {
        currentUser = AppticsUser(
          key,
          userProp["ap_user_id"]
        );
        return;
      }
    });
  }

  return currentUser;
}