I am getting a "Enter a valid phone number" error from the API

Topic summary

A developer is encountering an “Enter a valid phone number” error when attempting to update a Shopify customer’s phone number via the shopify_flutter package API.

Current Implementation:

  • Using phone format: +91 9878400227 (country code + space + number)
  • Calling ShopifyCustomer.customerUpdate() with the formatted phone string
  • Error response indicates the phone field is invalid

Technical Details:

  • Error code: INVALID
  • Affected field: customer.phone
  • The code constructs the phone number by concatenating countryCode and phone with a space

Status:
The issue remains unresolved. The developer is seeking guidance on whether their phone number formatting approach is incorrect or if there’s another issue with their implementation. No responses or solutions have been provided yet.

Summarized with AI on November 4. AI used: claude-sonnet-4-5-20250929.

I am trying to update a Shopify user using this flutter package. When I update the phone number, I am getting this error

customerUserErrors during customerUpdate: [{__typename: CustomerUserError, code: INVALID, field: [customer, phone], message: Enter a valid phone number}]

This is the phone number format that I am using to update it

+91 9878400227

This is my update function for the flutter code

try {
  ShopifyCustomer shopifyCustomer =
      ShopifyCustomer.instance;
  final phone =
      "${currentUser.countryCode} ${currentUser.phone}";
  log(phone);
  await shopifyCustomer.customerUpdate(
    customerAccessToken: currentUser.shopifyAccessToken,
    firstName: currentUser.name,
    phoneNumber: phone,
    email: currentUser.email,
    password: currentUser.password,
    lastName: currentUser.shopifyUser?.lastName,
    acceptsMarketing: true,
  );
  ShopifyAuth shopifyAuth = ShopifyAuth.instance;
  ShopifyUser? user =
      await shopifyAuth.currentUser(forceRefresh: true);
  currentUser.shopifyUser = user;
} catch (e) {
  log("Error updating shopify user:\n$e");
}

Is there anything that I am doing wrong. Do let me know.

Best Regards