woocommerce_flutter_api 1.0.2
woocommerce_flutter_api: ^1.0.2 copied to clipboard
A fully documented Flutter package for seamless WooCommerce integration. Easily manage products, orders, and customers with updated dependencies for a streamlined e-commerce experience.
WooCommerce Flutter API #
A comprehensive Flutter package for seamless WooCommerce integration. Easily manage authentication, notifications, cart, and product data with updated dependencies and full documentation.
Dependencies #
This package leverages the following dependencies:
- dio (^5.4.1) for HTTP requests
- faker (^2.1.0) for generating fake data during development
- flutter_secure_storage (^9.0.0) for secure data storage
- pretty_dio_logger (^1.3.1) for logging HTTP requests in a readable format
Installation #
To install the package, run:
flutter pub add woocommerce_flutter_api
Usage #
Create the main WooCommerce object to access all the features of the package:
final woocommerce = WooCommerce(
baseUrl: '<woocommerce-url>',
username: '<username>',
password: '<password>',
useFaker: true,
isDebug: true, // true by default
apiPath: '<some-custom-path>',
);
Using Fake Data (useFaker) #
The useFaker property is designed for development and testing purposes. When set to true, all API requests will return fake data generated by the faker package. This is especially useful if your WooCommerce backend is still under development—allowing you to build and test your application without relying on live data. Once your backend is ready, simply set useFaker to false to receive real data.
Example of initializing with fake data enabled:
final woocommerce = WooCommerce(
baseUrl: '<woocommerce-url>',
username: '<username>',
password: '<password>',
useFaker: true,
isDebug: true, // true by default
apiPath: '<some-custom-path>',
);
In this mode, every API call (e.g., authentication, notifications, cart, products) will return simulated responses, allowing you to continue development seamlessly until your WooCommerce backend is published.
Authentication #
Login and securely store the user ID:
await woocommerce.login('<email>', '<password>');
Notifications #
Fetch all notifications for the currently logged in user:
final notifications = await woocommerce.getNotifications();
Cart #
Retrieve the cart for the current user:
final cart = await woocommerce.getCart();
WooCommerce API #
Fetch a list of products:
final response = await woocommerce.getProducts();
Contributing #
Contributions are welcome! If you have suggestions, bug fixes, or improvements, please open an issue or submit a pull request. Your contributions will help make this package even better.