writeProfileInfo method

  1. @override
Future<void> writeProfileInfo({
  1. bool overwrite = false,
})
override

Implementation

@override
Future<void> writeProfileInfo({bool overwrite = false}) async {
  AppConfig.logger.d('writeProfileInfo');
  try {
    final box = await getBox(AppHiveBox.profile.name);

    String userId = box.get(AppHiveConstants.userId, defaultValue: '');

    if(userId.isEmpty || overwrite) {
      await box.put(AppHiveConstants.userId, userServiceImpl.user.id);
      await box.put(AppHiveConstants.username, userServiceImpl.user.name);
      await box.put(AppHiveConstants.profileId, userServiceImpl.profile.id);
      await box.put(AppHiveConstants.photoUrl, userServiceImpl.user.photoUrl);
      await box.put(AppHiveConstants.firstTime, false);
    }
  } catch (e) {
    AppConfig.logger.e('Error writing profile info: $e');
  }

}