flutter_simple_shopify 0.0.16-alpha

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

flutter_simple_shopify #

A new Flutter package which provides help in creating a mobile app of a shopify store. Note: This library as of right now is not ready for production however we finished creating our own app and used the library. There are still minor bugs here and there but we advise everyone to start using the library and post as many issues as possible. If there are questions about the usage feel free to hit us up on our mail address.

How To Use #

I Assume you have already a private app on your Shopify store. if not please follow this. At step 6 we recommend checking every API permission as some queries and mutations require permission on objects like product tags.

First of all configure the ShopifyConfig like that:

void main() {
  
  ShopifyConfig.setConfig(
      'de16cae1ce0b86260703fccaa6b689a3', // Storefront API access token.
      'exampleShopname.myshopify.com', // Store url.
      '2020-04'); // The Shopify Storefront API version.
  
  runApp(MyApp());
}

These are the four 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.

  ShopifyAuth shopifyAuth = ShopifyAuth.instance;
    Future<ShopifyUser> createUserWithEmailAndPassword({@required String email, @required String password})
    Future<void> signOutCurrentUser()
    Future<void> sendPasswordResetEmail({@required String email})
    Future<ShopifyUser> signInWithEmailAndPassword({@required String email, @required String password})
    Future<ShopifyUser> currentUser()
  ShopifyStore shopifyStore = ShopifyStore.instance;
     Future<List<Product>> getProductsByIds()
     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> getFeaturedCollection()
     Future<List<Collection>> getAllCollections()
     Future<List<Product>> getXProductsAfterCursorWithinCollection(String id, int limit, String startCursor, SortKeyProduct sortKey)
     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)
  ShopifyCheckout shopifyCheckout = ShopifyCheckout.instance;
    Future<Checkout> getCheckoutInfoQuery({String checkoutId})
    Future<List<Order>> getAllOrders({String customerAccessToken})
    Future<void> checkoutLineItemsReplace({String checkoutId, List<Map<String,dynamic>> checkoutLineItems})
    Future<void> checkoutCustomerAssociate({String checkoutId, String customerAccessToken}) 
    Future<void> checkoutCustomerDisassociate({String checkoutId})
    Future<void> checkoutDiscountCodeApply({String checkoutId, String discountCode})
    Future<void> checkoutDiscountCodeRemove({String checkoutId})
    Future<String> createCheckout()
    Future<void> checkoutGiftCardAppend(String checkoutId, List<String> giftCardCodes)
    Future<void> checkoutGiftCardRemove(String appliedGiftCardId, String checkoutId)
  ShopifyCustomer shopifyCustomer = ShopifyCustomer.instance;
     Future<void> customerAddressUpdate({String address1, String address2, String company, String city, String country, String firstName, String lastName, String phone, String province, String zip, String customerAccessToken, id})
     Future<void> customerUpdate({String email, String firstName, String lastName, String password, String phoneNumber, String customerAccessToken, bool acceptsMarketing})
     Future<void> 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})
       
  ShopifyBlog shopifyBlog = ShopifyBlog.instance;
     Future<List<Blog>> getAllBlogs()
     Future<Blog> getBlogByHandle(String handle, SortKeyArticle sortKeyArticle)
     Future<List<Article>> getXArticlesSorted({int articleAmount, SortKeyArticle sortKeyArticle})

Above you see the instance on top and the possible methods and functions which you can use.

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.0.1-alpha] - 24/04/2020 #

  • initial release - not production ready

[0.0.2-alpha] - 26/04/2020 #

  • added 3 new methods - not production ready

[0.0.3-alpha] - 02/05/2020 #

  • added ShopifyBlog with 3 new methods.

[0.0.4-alpha] - 02/05/2020 #

  • added null checks on the models.

[0.0.5-alpha] - 02/05/2020 #

  • fixed a minor bug @ getCheckoutInfoQuery and added 2 new methods

[0.0.6-alpha] - 04/05/2020 #

  • added 2 new methods and new enum, changed parameters

[0.0.7-alpha] - 07/05/2020 #

  • new User model, created all login functionality

[0.0.8-alpha] - 08/05/2020 #

  • new Shop model, made adding lineitems to checkout easier

[0.0.9-alpha] - 09/05/2020 #

  • minor changes

[0.0.10-alpha] - 14/05/2020 #

  • now checking for query/mutation errors and throwing exceptions if something bad happens

[0.0.11-alpha] - 14/05/2020 #

  • 0.0.11- Products now have images and some other minor changes

[0.0.12-alpha] - 14/05/2020 #

  • Price property now has a currency symbol and a formatted price. also you can now reverse the list at getNProducts()

[0.0.13-alpha] - 14/05/2020 #

  • added example

[0.0.14-alpha] - 14/05/2020 #

  • added example

[0.0.15-alpha] - 22/06/2020 #

  • added reverse to every possible function that fetches lists.
  • fixed problem where one had to make sure every legal field has information in it. (eg. not having any text in privacy policy would cause problems)
  • fixed problem where creating a user account with exisitng email adress would not throw proper error message.
  • parameters reverse and deletePartofCache are optional now.
  • added collection sortKey

had to delete the example folder, will add in new version again.

[0.0.1-thinkSimple] - 22/06/2020 #

  • version just for our purpose

[0.0.2-thinkSimple] - 23/06/2020 #

  • Clarification: Do not use this version, we only use it for our clients app's. The normal version has more functionality!

[0.0.3-thinkSimple] - 23/06/2020 #

  • Minor Bug fixes

[0.0.16-alpha] - 22/06/2020 #

  • fixed the breaking bug in the last version.
  • collections are fetched different now which translates directly into loading time. (way faster)

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_simple_shopify/flutter_simple_shopify.dart';
import 'collection_tab.dart';
import 'home_tab.dart';
import 'profile_tab.dart';
import 'search_tab.dart';

void main() {
  ShopifyConfig.setConfig(
    "STOREFRONT-API-ACCESS-TOKEN",
    "YOUR-SHOPIFY-WEBSITE",
    "2020-04",
  );
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Shopify Example',
      theme: ThemeData(primaryColor: Colors.redAccent),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _currentIndex = 0;

  final _tabs = [
    HomeTab(),
    CollectionTab(),
    SearchTab(),
    ProfileTab(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _currentIndex,
        children: _tabs,
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        onTap: _onNavigationBarItemClick,
        fixedColor: Theme.of(context).primaryColor,
        unselectedItemColor: Colors.black,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("Home")),
          BottomNavigationBarItem(
              icon: Icon(Icons.category), title: Text("Collections")),
          BottomNavigationBarItem(
              icon: Icon(Icons.search), title: Text("Search")),
          BottomNavigationBarItem(
              icon: Icon(Icons.person), title: Text("Profile")),
        ],
      ),
    );
  }

  void _onNavigationBarItemClick(int index) {
    setState(() {
      _currentIndex = index;
    });
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_simple_shopify: ^0.0.16-alpha

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_simple_shopify/flutter_simple_shopify.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because:

  • package:flutter_simple_shopify/flutter_simple_shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/src/shopify_auth.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: linux

Package does not support Flutter platform ios

Because:

  • package:flutter_simple_shopify/flutter_simple_shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/src/shopify_auth.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: linux

Package does not support Flutter platform macos

Because:

  • package:flutter_simple_shopify/flutter_simple_shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/src/shopify_auth.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: linux

Package does not support Flutter platform web

Because:

  • package:flutter_simple_shopify/flutter_simple_shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/src/shopify_auth.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: linux

Package does not support Flutter platform windows

Because:

  • package:flutter_simple_shopify/flutter_simple_shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/shopify.dart that imports:
  • package:flutter_simple_shopify/shopify/src/shopify_auth.dart that imports:
  • package:shared_preferences/shared_preferences.dart that declares support for platforms: android, ios, linux, macos, web

Package not compatible with SDK dart

Because:

  • flutter_simple_shopify that is a package requiring null.

Health suggestions

Fix lib/shopify/src/shopify_store.dart. (-0.50 points)

Analysis of lib/shopify/src/shopify_store.dart reported 1 hint:

line 15 col 8: Unused import: '../../graphql_operations/queries/get_collections.dart'.

Format lib/enums/enums.dart.

Run flutter format to format lib/enums/enums.dart.

Format lib/enums/src/sort_key_article.dart.

Run flutter format to format lib/enums/src/sort_key_article.dart.

Fix additional 67 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/enums/src/sort_key_blog.dart (Run flutter format to format lib/enums/src/sort_key_blog.dart.)
  • lib/enums/src/sort_key_collection.dart (Run flutter format to format lib/enums/src/sort_key_collection.dart.)
  • lib/enums/src/sort_key_order.dart (Run flutter format to format lib/enums/src/sort_key_order.dart.)
  • lib/enums/src/sort_key_product.dart (Run flutter format to format lib/enums/src/sort_key_product.dart.)
  • lib/enums/src/sort_key_product_collection.dart (Run flutter format to format lib/enums/src/sort_key_product_collection.dart.)
  • lib/flutter_simple_shopify.dart (Run flutter format to format lib/flutter_simple_shopify.dart.)
  • lib/graphql_operations/mutations/access_token_delete.dart (Run flutter format to format lib/graphql_operations/mutations/access_token_delete.dart.)
  • lib/graphql_operations/mutations/add_item(s)_to_checkout.dart (Run flutter format to format lib/graphql_operations/mutations/add_item(s)_to_checkout.dart.)
  • lib/graphql_operations/mutations/checkout_associate_customer.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_associate_customer.dart.)
  • lib/graphql_operations/mutations/checkout_customer_disassociate.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_customer_disassociate.dart.)
  • lib/graphql_operations/mutations/checkout_discount_code_apply.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_discount_code_apply.dart.)
  • lib/graphql_operations/mutations/checkout_discount_code_remove.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_discount_code_remove.dart.)
  • lib/graphql_operations/mutations/checkout_email_update.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_email_update.dart.)
  • lib/graphql_operations/mutations/checkout_giftcard_remove.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_giftcard_remove.dart.)
  • lib/graphql_operations/mutations/checkout_giftcards_append.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_giftcards_append.dart.)
  • lib/graphql_operations/mutations/checkout_shipping_address_update.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_shipping_address_update.dart.)
  • lib/graphql_operations/mutations/checkout_shipping_line_update.dart (Run flutter format to format lib/graphql_operations/mutations/checkout_shipping_line_update.dart.)
  • lib/graphql_operations/mutations/complete_checkout_free.dart (Run flutter format to format lib/graphql_operations/mutations/complete_checkout_free.dart.)
  • lib/graphql_operations/mutations/complete_checkout_visa.dart (Run flutter format to format lib/graphql_operations/mutations/complete_checkout_visa.dart.)
  • lib/graphql_operations/mutations/create_checkout.dart (Run flutter format to format lib/graphql_operations/mutations/create_checkout.dart.)
  • lib/graphql_operations/mutations/customer_access_token_create.dart (Run flutter format to format lib/graphql_operations/mutations/customer_access_token_create.dart.)
  • lib/graphql_operations/mutations/customer_address_create.dart (Run flutter format to format lib/graphql_operations/mutations/customer_address_create.dart.)
  • lib/graphql_operations/mutations/customer_address_delete.dart (Run flutter format to format lib/graphql_operations/mutations/customer_address_delete.dart.)
  • lib/graphql_operations/mutations/customer_address_update.dart (Run flutter format to format lib/graphql_operations/mutations/customer_address_update.dart.)
  • lib/graphql_operations/mutations/customer_default_address_update.dart (Run flutter format to format lib/graphql_operations/mutations/customer_default_address_update.dart.)
  • lib/graphql_operations/mutations/customer_recover.dart (Run flutter format to format lib/graphql_operations/mutations/customer_recover.dart.)
  • lib/graphql_operations/mutations/customer_reset.dart (Run flutter format to format lib/graphql_operations/mutations/customer_reset.dart.)
  • lib/graphql_operations/mutations/customer_reset_by_url.dart (Run flutter format to format lib/graphql_operations/mutations/customer_reset_by_url.dart.)
  • lib/graphql_operations/mutations/customer_update.dart (Run flutter format to format lib/graphql_operations/mutations/customer_update.dart.)
  • lib/graphql_operations/mutations/remove_checkout_items.dart (Run flutter format to format lib/graphql_operations/mutations/remove_checkout_items.dart.)
  • lib/graphql_operations/queries/get_all_blogs.dart (Run flutter format to format lib/graphql_operations/queries/get_all_blogs.dart.)
  • lib/graphql_operations/queries/get_all_collections_optimized.dart (Run flutter format to format lib/graphql_operations/queries/get_all_collections_optimized.dart.)
  • lib/graphql_operations/queries/get_all_orders.dart (Run flutter format to format lib/graphql_operations/queries/get_all_orders.dart.)
  • lib/graphql_operations/queries/get_all_products_on_query.dart (Run flutter format to format lib/graphql_operations/queries/get_all_products_on_query.dart.)
  • lib/graphql_operations/queries/get_blog_by_handle.dart (Run flutter format to format lib/graphql_operations/queries/get_blog_by_handle.dart.)
  • lib/graphql_operations/queries/get_checkout_info_requires_shipping.dart (Run flutter format to format lib/graphql_operations/queries/get_checkout_info_requires_shipping.dart.)
  • lib/graphql_operations/queries/get_checkout_information.dart (Run flutter format to format lib/graphql_operations/queries/get_checkout_information.dart.)
  • lib/graphql_operations/queries/get_checkout_without_shipping_rates.dart (Run flutter format to format lib/graphql_operations/queries/get_checkout_without_shipping_rates.dart.)
  • lib/graphql_operations/queries/get_collections.dart (Run flutter format to format lib/graphql_operations/queries/get_collections.dart.)
  • lib/graphql_operations/queries/get_customer.dart (Run flutter format to format lib/graphql_operations/queries/get_customer.dart.)
  • lib/graphql_operations/queries/get_featured_collections.dart (Run flutter format to format lib/graphql_operations/queries/get_featured_collections.dart.)
  • lib/graphql_operations/queries/get_n_articles_sorted.dart (Run flutter format to format lib/graphql_operations/queries/get_n_articles_sorted.dart.)
  • lib/graphql_operations/queries/get_n_products.dart (Run flutter format to format lib/graphql_operations/queries/get_n_products.dart.)
  • lib/graphql_operations/queries/get_products.dart (Run flutter format to format lib/graphql_operations/queries/get_products.dart.)
  • lib/graphql_operations/queries/get_products_by_handle.dart (Run flutter format to format lib/graphql_operations/queries/get_products_by_handle.dart.)
  • lib/graphql_operations/queries/get_products_by_ids.dart (Run flutter format to format lib/graphql_operations/queries/get_products_by_ids.dart.)
  • lib/graphql_operations/queries/get_shop.dart (Run flutter format to format lib/graphql_operations/queries/get_shop.dart.)
  • lib/graphql_operations/queries/get_web_url.dart (Run flutter format to format lib/graphql_operations/queries/get_web_url.dart.)
  • lib/graphql_operations/queries/get_x_products_after_cursor.dart (Run flutter format to format lib/graphql_operations/queries/get_x_products_after_cursor.dart.)
  • lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart (Run flutter format to format lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart.)
  • lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart (Run flutter format to format lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart.)
  • lib/mixins/mixins.dart (Run flutter format to format lib/mixins/mixins.dart.)
  • lib/mixins/src/shopfiy_error.dart (Run flutter format to format lib/mixins/src/shopfiy_error.dart.)
  • lib/models/models.dart (Run flutter format to format lib/models/models.dart.)
  • lib/models/src/article.dart (Run flutter format to format lib/models/src/article.dart.)
  • lib/models/src/blog.dart (Run flutter format to format lib/models/src/blog.dart.)
  • lib/models/src/checkout.dart (Run flutter format to format lib/models/src/checkout.dart.)
  • lib/models/src/order.dart (Run flutter format to format lib/models/src/order.dart.)
  • lib/models/src/product.dart (Run flutter format to format lib/models/src/product.dart.)
  • lib/models/src/shop.dart (Run flutter format to format lib/models/src/shop.dart.)
  • lib/models/src/shopify_user.dart (Run flutter format to format lib/models/src/shopify_user.dart.)
  • lib/shopify/shopify.dart (Run flutter format to format lib/shopify/shopify.dart.)
  • lib/shopify/src/shopify_auth.dart (Run flutter format to format lib/shopify/src/shopify_auth.dart.)
  • lib/shopify/src/shopify_blog.dart (Run flutter format to format lib/shopify/src/shopify_blog.dart.)
  • lib/shopify/src/shopify_checkout.dart (Run flutter format to format lib/shopify/src/shopify_checkout.dart.)
  • lib/shopify/src/shopify_customer.dart (Run flutter format to format lib/shopify/src/shopify_customer.dart.)
  • lib/shopify_config.dart (Run flutter format to format lib/shopify_config.dart.)

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
graphql ^3.0.0 3.0.2 4.0.0-alpha.1
shared_preferences ^0.5.7 0.5.8
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
file 5.2.1
flutter_web_plugins 0.0.0
gql 0.12.3 0.12.4-alpha+1594319799502
http 0.12.1
http_parser 3.1.4
intl 0.16.1
matcher 0.12.8
meta 1.1.8 1.2.2
mime 0.9.6+3
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_platform_interface 1.0.2
pedantic 1.9.0 1.9.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
quiver 2.1.3
rxdart 0.23.1 0.24.1
shared_preferences_linux 0.0.2+1
shared_preferences_macos 0.0.1+10
shared_preferences_platform_interface 1.0.4
shared_preferences_web 0.1.2+7
sky_engine 0.0.99
source_span 1.7.0
stack_trace 1.9.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
uuid_enhanced 3.0.2
vector_math 2.0.8 2.1.0-nullsafety
websocket 0.0.5
xdg_directories 0.1.0
Dev dependencies
flutter_test