setUserId method

Future<void> setUserId(
  1. String? userId
)

Sets the userId in the cache. If the userId is null, it will be removed from the cache. This is used to identify the user in the AppFit dashboard.

When setting the userId, the anonymousId will be set to null.

Implementation

Future<void> setUserId(String? userId) async {
  final sharedPreferences = await SharedPreferences.getInstance();
  if (userId == null) {
    await sharedPreferences.remove(_AppFitCacheKey.userId.name);
    return;
  }
  await sharedPreferences.setString(_AppFitCacheKey.userId.name, userId);
}