shopify_flutter
A flutter package that works as a bridge between your Shopify Store and Flutter Application.
Support
If you like the package and find it helpful, you can Buy Me MO:MO.
How To Use
Create a private app on your Shopify store. Please follow THIS DOC to get started with it.
While creating storefront api access token, makes sure to check all the api permissions as some queries and mutations require permission on objects like product tags.
First of all configure the ShopifyConfig like that:
void main() {
ShopifyConfig.setConfig(
storefrontAccessToken: '*******************',
storeUrl: '*****.myshopify.com',
// Optional | Needed only if needed to call admin api
adminAccessToken: "shpat_*******************",
// optional | default: 2026-07
storefrontApiVersion: '2026-07',
// optional | default: null
cachePolicy: CachePolicy.cacheAndNetwork,
// Store locale | default : en
language: 'en',
// optional | default: in-memory GraphQLCache()
// Inject a custom GraphQLCache for the Storefront client (e.g. disk-backed
// via HiveStore from graphql_flutter).
storefrontCache: GraphQLCache(store: await HiveStore.open()),
// optional | default: in-memory GraphQLCache()
// Inject a custom GraphQLCache for the Admin client.
adminCache: GraphQLCache(store: await HiveStore.open(boxName: 'admin')),
// optional | default: 30s
queryRequestTimeout: const Duration(seconds: 30)
);
runApp(MyApp());
}
adminAccessTokenis only required for admin api calls likedeleteCustomer(). If you are not using that function, you may not need to provide it.
storefrontApiVersiondefault vesion is set to '2026-07'. This package requires 2026-07 or newer (the cart operations rely on fields added in 2026-07). Shopify supports each version for 12 months after release and then falls forward to the oldest supported version, so prefer keeping this current.
languagedefaults to 'en'. It is the default locale/language of the store. Only takes effect if the store supports provided language code.
storefrontCache/adminCachelet you supply aGraphQLCachefromgraphql_flutterso query results can be persisted to disk (e.g. viaHiveStore) and survive app restarts. When omitted, fresh in-memory caches are created as before.
These are the possible instances, each contains different methods which will help you with working with the Shopify Storefront API.
The goal is to make creating an mobile app from your Shopify website easier.
Error handling
Every method throws a ShopifyException when a call fails — whether Shopify
returned GraphQL/user errors, or the request never completed (no connectivity,
timeout, HTTP error). One catch covers both:
try {
final products = await ShopifyStore.instance.getAllProducts();
} on ShopifyException catch (e) {
// e.key -> the operation, e.g. 'cartLinesAdd'
// e.errorKey -> the kind of error, e.g. 'userErrors'
// e.errors -> the messages Shopify returned
print(e);
}
ShopifyException is exported from package:shopify_flutter/shopify_flutter.dart.
Changed in 3.1.0. Failed requests previously threw a bare
String— which is not anException, soon Exception catchdid not catch it, and for connectivity errors the thrown value was an empty string with the real cause discarded. If you relied on catching aString, switch toShopifyException. Code using a barecatch (e)keeps working.
Shopify Auth
ShopifyAuth shopifyAuth = ShopifyAuth.instance;
Future<ShopifyUser> signInWithEmailAndPassword({
required String email,
required String password
})
Future<ShopifyUser> createUserWithEmailAndPassword({
required String email,
required String password,
String? phone,
String? firstName,
String? lastName,
bool? acceptsMarketing
})
Future<void> signOutCurrentUser()
Future<void> sendPasswordResetEmail({required String email})
Future<ShopifyUser?> currentUser({bool forceRefresh = false})
Future<void> deleteCustomer({required String userId})
Future<String?> get currentCustomerAccessToken
Future<bool> get isAccessTokenExpired
Future<AccessTokenWithExpDate?> get accessTokenWithExpDate
Shopify Store
ShopifyStore shopifyStore = ShopifyStore.instance;
Future<List<Product>> getProductsByIds(List<String> productIds)
Future<List<Product>> getXProductsAfterCursor(
int limit,
String startCursor
)
Future<List<Product>> getAllProducts()
Future<List<Product>> getNProducts({
required int n,
required SortKey sortKey
})
Future<Shop> getShop()
Future<Collection?> getCollectionById(String collectionId)
Future<List<Collection>> getAllCollections()
Future<List<Product>> getAllProductsFromCollectionById(String id)
Future<List<Product>> getAllProductsOnQuery(
String cursor,
SortKeyProduct sortKey,
String query
)
Future<List<Product>> getXProductsOnQueryAfterCursor(
String cursor,
int limit,
SortKeyProduct sortKey,
String query
)
/// filters available queries
Future<List<Product>> getXProductsAfterCursorWithinCollection(
String id,
int limit,
String startCursor,
SortKeyProduct sortKey,
Map<String, dynamic>? filters
)
Future<List<Product>> searchProducts(
String query,
{
int limit = 15,
String? startCursor,
SearchSortKeys sortKey =
SearchSortKeys.RELEVANCE,
bool reverse = false,
Map<String, dynamic>? filters
}
)
Example to get metafields in product
final products = await shopifyStore.getProductsByIds(
[id],
metafields: [
MetafieldIdentifier(key: 'content-about-the-brand', namespace: 'pim'),
MetafieldIdentifier(key: 'pdp_content_image_1_mobile', namespace: 'custom'),
MetafieldIdentifier(key: 'pdp_content_image_2_mobile', namespace: 'custom'),
MetafieldIdentifier(key: 'pdp_content_image_3_mobile', namespace: 'custom'),
//...
],
);
Shopify Cart
ShopifyCart shopifyCart = ShopifyCart.instance;
Future<Cart?> getCartById(String cartId, {bool reverse = false})
Future<Cart> createCart(CartInput cartInput)
Future<Cart> addLineItemsToCart({
required String cartId,
required List<CartLineInput> cartLineInputs,
bool reverse = false,
})
Future<Cart> removeLineItemsFromCart({
required String cartId,
required List<String> lineIds,
bool reverse = false,
})
Future<Cart> updateLineItemsInCart({
required String cartId,
required List<CartLineInput> cartLineInputs,
bool reverse = false,
})
Future<Cart> updateNoteInCart({
required String cartId,
required String note,
bool reverse = false,
})
Future<Cart> updateCartDiscountCodes({
required String cartId,
required List<String> discountCodes,
bool reverse = false,
})
/// Adds delivery addresses to an existing cart.
/// Replaces the removed `buyerIdentity.deliveryAddressPreferences`.
Future<Cart> addDeliveryAddresses({
required String cartId,
required List<CartSelectableAddressInput> addresses,
bool reverse = false,
})
Future<Cart> updateBuyerIdentityInCart({
required String cartId,
required CartBuyerIdentityInput buyerIdentity,
bool reverse = false,
})
Future<Cart> updateCartAttributes({
required String cartId,
required List<AttributeInput> attributes,
bool reverse = false,
})
Shopify Order
ShopifyOrder shopifyOrder = ShopifyOrder.instance;
Future<List<Order>> getAllOrders({String customerAccessToken})
Shopify Customer
ShopifyCustomer shopifyCustomer = ShopifyCustomer.instance;
Future<void> customerAddressUpdate({
required String customerAccessToken,
required String id,
String? address1,
String? address2,
String? company,
String? city,
String? country,
String? firstName,
String? lastName,
String? phone,
String? province,
String? zip,
})
Future<void> customerUpdate({
String? email,
String? firstName,
String? lastName,
String? password,
String? phoneNumber,
String? customerAccessToken,
bool? acceptsMarketing
})
Future<Address> customerAddressCreate({
String? address1,
String? address2,
String? company,
String? city,
String? country,
String? firstName,
String? lastName,
String? phone,
String? province,
String? zip,
String? customerAccessToken
})
Future<void> customerAddressDelete({
String? customerAccessToken,
String? addressId
})
Future<void> customerDefaultAddressUpdate({
required String addressId,
required String customerAccessToken
})
Shopify Blog
ShopifyBlog shopifyBlog = ShopifyBlog.instance;
Future<List<Blog>> getAllBlogs()
Future<Blog> getBlogByHandle(
String handle,
SortKeyArticle sortKeyArticle
)
Future<List<Article>> getXArticlesSorted({
int articleAmount,
SortKeyArticle sortKeyArticle
})
Shopify Page
ShopifyPage shopifyPage = ShopifyPage.instance;
Future<List<Page>> getAllPages()
Future<Page> getPageByHandle(String handle)
Shopify Localization
ShopifyLocalization shopifyLocalizatoin = ShopifyLocalization.instance;
Future<Localization> getLocalization()
// Used to change currency units. eg: "US", "NP", "JP" etc. Only takes effect if the store supports provided currency.
void setCountryCode(String? countryCode)
// Used to set language code, eg: "EN", "DE", "FIL", "ZH_CN" etc.
void setLanguageCode(String? languageCode)
// Getters
countryCode // get the stored country code
languageCode // get the stored language code
Shopify Custom
ShopifyCustom shopifyCustom = ShopifyCustom.instance;
Future<Map<String, dynamic>?> customQuery({
required String gqlQuery,
Map<String, dynamic> variables = const {},
bool adminAccess = false
})
Future<Map<String, dynamic>?> customMutation({
required String gqlMutation,
Map<String, dynamic> variables = const {},
bool adminAccess = false
})
Above you see the instance on top and the possible methods and functions which you can use.
Filter Products
filters is a Map of String and dynmaic. Filter by price and availability are availabe by default.
Example:
1. gets products with a price between 100 and 500
{"price": {"min":100, "max":500} }
2. gets products with a price between 100 and 500 which are available
{"price": {"min":100, "max":500}, "available": true} }
3. gets products with a variant option with name "color" and value "blue"
{ "variantOption": { "name": "color", "value": "blue" } }
Configure Filters

For more information about filters visit:
Contribution
Everybody can contribute and is invited to do so!
Important: If you add a new field to a model please consider also adding this to every mutation/query that is associated with the model.
Example: adding a new field to Cart means going through every cart query/mutation in lib/graphql_operations/storefront/ and adding it to each one.
(adding a new field to a Model also requires you to update the fromJson)
Libraries
- enums/enums
- enums/src/payment_token_type
- enums/src/sort_key_article
- enums/src/sort_key_blog
- enums/src/sort_key_collection
- enums/src/sort_key_order
- enums/src/sort_key_page
- enums/src/sort_key_product
- enums/src/sort_key_product_collection
- enums/src/sort_key_product_search
- graphql_operations/admin/mutations/customer_delete
- graphql_operations/storefront/mutations/access_token_delete
- graphql_operations/storefront/mutations/cart/cart_attributes_update_mutation
- graphql_operations/storefront/mutations/cart/cart_buyer_identity_update
- graphql_operations/storefront/mutations/cart/cart_create
- graphql_operations/storefront/mutations/cart/cart_delivery_addresses_add
- graphql_operations/storefront/mutations/cart/cart_discount_code_update_mutation
- graphql_operations/storefront/mutations/cart/cart_line_item_add
- graphql_operations/storefront/mutations/cart/cart_line_item_remove
- graphql_operations/storefront/mutations/cart/cart_line_item_update
- graphql_operations/storefront/mutations/cart/cart_note_update
- graphql_operations/storefront/mutations/customer_access_token_create
- graphql_operations/storefront/mutations/customer_access_token_create_with_multipass
- graphql_operations/storefront/mutations/customer_access_token_renew
- graphql_operations/storefront/mutations/customer_address_create
- graphql_operations/storefront/mutations/customer_address_delete
- graphql_operations/storefront/mutations/customer_address_update
- graphql_operations/storefront/mutations/customer_create
- graphql_operations/storefront/mutations/customer_default_address_update
- graphql_operations/storefront/mutations/customer_recover
- graphql_operations/storefront/mutations/customer_reset
- graphql_operations/storefront/mutations/customer_reset_by_url
- graphql_operations/storefront/mutations/customer_update
- graphql_operations/storefront/queries/get_all_blogs
- graphql_operations/storefront/queries/get_all_collections_optimized
- graphql_operations/storefront/queries/get_all_orders
- graphql_operations/storefront/queries/get_all_pages
- graphql_operations/storefront/queries/get_all_products_from_collection_by_id
- graphql_operations/storefront/queries/get_all_products_on_query
- graphql_operations/storefront/queries/get_blog_by_handle
- graphql_operations/storefront/queries/get_cart_by_id
- graphql_operations/storefront/queries/get_collection_by_id
- graphql_operations/storefront/queries/get_collections
- graphql_operations/storefront/queries/get_collections_by_ids
- graphql_operations/storefront/queries/get_customer
- graphql_operations/storefront/queries/get_featured_collections
- graphql_operations/storefront/queries/get_n_articles_sorted
- graphql_operations/storefront/queries/get_n_products
- graphql_operations/storefront/queries/get_page_by_handle
- graphql_operations/storefront/queries/get_product_by_handle
- graphql_operations/storefront/queries/get_product_recommendations
- graphql_operations/storefront/queries/get_products
- graphql_operations/storefront/queries/get_products_by_ids
- graphql_operations/storefront/queries/get_shop
- graphql_operations/storefront/queries/get_x_collections_and_n_products_sorted
- graphql_operations/storefront/queries/get_x_products_after_cursor
- graphql_operations/storefront/queries/get_x_products_after_cursor_within_collection
- graphql_operations/storefront/queries/get_x_products_on_query_after_cursor
- graphql_operations/storefront/queries/localization_query
- graphql_operations/storefront/queries/search_product
- mixins/mixins
- mixins/src/shopify_error
- models/json_helper
- models/models
- models/src/address_autocomplete/address_details/address_details
- models/src/address_autocomplete/address_prediction/address_prediction
- models/src/address_autocomplete/location_input/location_input
- models/src/address_autocomplete/matched_substring/matched_substring
- models/src/article/article
- models/src/article/articles/articles
- models/src/article/comment/comment
- models/src/blog/blog
- models/src/blog/blogs/blogs
- models/src/cart/attribute/attribute
- models/src/cart/cart
- models/src/cart/cart_buyer_identity/cart_buyer_identity
- models/src/cart/cart_cost/cart_cost
- models/src/cart/cart_delivery/cart_delivery
- models/src/cart/cart_delivery/cart_delivery_address/cart_delivery_address
- models/src/cart/cart_delivery/cart_selectable_address/cart_selectable_address
- models/src/cart/cart_dicount_code/cart_discount_code
- models/src/cart/cart_discount_allocation/cart_discount_allocation
- models/src/cart/cart_model
- models/src/cart/cart_preference/cart_delivery_coordinates_preference/cart_delivery_coordinates_preference
- models/src/cart/cart_preference/cart_delivery_preference/cart_delivery_preference
- models/src/cart/cart_preference/cart_preference
- models/src/cart/customer/customer
- models/src/cart/inputs/attribute_input/attribute_input
- models/src/cart/inputs/cart_address_input/cart_address_input
- models/src/cart/inputs/cart_buyer_identity_input/cart_buyer_identity_input
- models/src/cart/inputs/cart_delivery_address_input/cart_delivery_address_input
- models/src/cart/inputs/cart_delivery_input/cart_delivery_input
- models/src/cart/inputs/cart_input/cart_input
- models/src/cart/inputs/cart_inputs
- models/src/cart/inputs/cart_line_input/cart_line_input
- models/src/cart/inputs/cart_line_update_input/cart_line_update_input
- models/src/cart/inputs/cart_selectable_address_input/cart_selectable_address_input
- models/src/cart/inputs/mailing_address_input/mailing_address_input
- models/src/cart/lines/cart_line_cost/cart_line_cost
- models/src/cart/lines/line/line
- models/src/cart/lines/lines
- models/src/collection/collection
- models/src/collection/collections/collections
- models/src/localization/country/country
- models/src/localization/currency/currency
- models/src/localization/language/language
- models/src/localization/localization
- models/src/mailing_address/mailing_address
- models/src/order/discount_allocations/discount_allocations
- models/src/order/line_item_order/line_item_order
- models/src/order/line_items_order/line_items_order
- models/src/order/order
- models/src/order/orders/orders
- models/src/order/shipping_address/shipping_address
- models/src/order/successful_fulfillment/successful_fulfilment_tracking_info/successful_fulfilment_tracking_info
- models/src/order/successful_fulfillment/successful_fullfilment
- models/src/page/page
- models/src/page/pages/pages
- models/src/product/associated_collections/associated_collections
- models/src/product/metafield/metafield
- models/src/product/metafield_identifier/metafield_identifier
- models/src/product/option/option
- models/src/product/price_v_2/price_v_2
- models/src/product/product
- models/src/product/product_media/product_media
- models/src/product/product_option_value/product_option_value
- models/src/product/product_variant/product_variant
- models/src/product/products/products
- models/src/product/selected_option/selected_option
- models/src/product/selling_plan_allocation/selling_plan/checkout_charge/checkout_charge
- models/src/product/selling_plan_allocation/selling_plan/price_adjustments/price_adjustments
- models/src/product/selling_plan_allocation/selling_plan/selling_plan
- models/src/product/selling_plan_allocation/selling_plan/selling_plan_option/selling_plan_option
- models/src/product/selling_plan_allocation/selling_plan_allocation
- models/src/product/shopify_image/shopify_image
- models/src/product/taxonomy_category/taxonomy_category
- models/src/product/unit_price_measurement/unit_price_measurement
- models/src/shop/payment_settings/payment_settings
- models/src/shop/primary_domain/primary_domain
- models/src/shop/privacy_policy/privacy_policy
- models/src/shop/refund_policy/refund_policy
- models/src/shop/shipping_policy/shipping_policy
- models/src/shop/shop
- models/src/shop/subscription_policy/subscription_policy
- models/src/shop/terms_of_service/terms_of_service
- models/src/shopify_user/access_token_with_exp_date
- models/src/shopify_user/address/address
- models/src/shopify_user/addresses/addresses
- models/src/shopify_user/shopify_user
- shopify/shopify
- shopify/src/shopify_auth
- shopify/src/shopify_blog
- shopify/src/shopify_cart
- shopify/src/shopify_custom
- shopify/src/shopify_customer
- shopify/src/shopify_localization
- shopify/src/shopify_order
- shopify/src/shopify_page
- shopify/src/shopify_store
- shopify_config
- shopify_flutter