currentUser method

Future<ShopifyUser?> currentUser({
  1. bool forceRefresh = false,
})

Returns the currently signed-in ShopifyUser or null if there is none.

If forceRefresh is set to true, it will fetch the user from the server.

Implementation

Future<ShopifyUser?> currentUser({
  bool forceRefresh = false,
}) async {
  final accessToken = await currentCustomerAccessToken;
  if (accessToken == null) {
    await signOutCurrentUser();
    return null;
  }

  if (forceRefresh) {
    return _getShopifyUser(accessToken);
  } else if (_shopifyUser.containsKey(ShopifyConfig.storeUrl)) {
    return _shopifyUser[ShopifyConfig.storeUrl];
  } else {
    return _getShopifyUser(accessToken);
  }
}