flutter_magento 2.0.0
flutter_magento: ^2.0.0 copied to clipboard
A comprehensive Flutter plugin for Magento e-commerce platform integration
π Flutter Magento Plugin #
A comprehensive Flutter plugin for Magento e-commerce platform integration, providing 200+ functions for building modern mobile commerce applications.
β¨ Features #
π Authentication & Customer Management #
- Customer login/logout with JWT tokens
- Customer registration and profile management
- Password reset and change
- Social authentication (Google, Facebook, Apple)
- Address book management
- Customer preferences and groups
ποΈ Product Catalog & Management #
- Product listing with advanced filters
- Product search with autocomplete
- Category management and navigation
- Product variants and options
- Product media gallery (images, videos, 360Β° views)
- Product reviews and ratings
- Related products and recommendations
π Shopping Cart & Checkout #
- Guest and customer cart management
- Add/remove/update cart items
- Apply coupons and gift cards
- Cart validation and totals
- Shipping estimation and methods
- Payment method selection
- Order placement and confirmation
π Order Management #
- Order history and details
- Order status tracking
- Order cancellation and returns
- Invoice and shipment management
- Credit memo processing
- Reorder functionality
β€οΈ Wishlist & Favorites #
- Multiple wishlist support
- Add/remove products
- Share wishlists
- Wishlist to cart conversion
- Wishlist analytics
π Advanced Search & Filtering #
- Full-text search with suggestions
- Attribute-based filtering
- Price range filtering
- Availability filtering
- Filter combinations and saving
- Search analytics and trends
π± Enhanced User Experience #
- Offline mode support
- Performance optimization
- Push notifications
- Multi-language support
- Dark/light theme support
π Getting Started #
Installation #
Add the dependency to your pubspec.yaml
:
dependencies:
flutter_magento: ^2.0.0
Basic Usage #
import 'package:flutter_magento/flutter_magento.dart';
void main() async {
// Initialize the plugin
final magento = FlutterMagento();
await magento.initialize(
baseUrl: 'https://your-magento-store.com',
headers: {'Content-Type': 'application/json'},
);
// Authenticate customer
try {
final authResponse = await magento.authenticateCustomer(
email: 'customer@example.com',
password: 'password123',
);
print('Customer authenticated: ${authResponse.customer.firstName}');
} catch (e) {
print('Authentication failed: $e');
}
}
π API Reference #
Authentication #
// Customer login
final authResponse = await magento.authenticateCustomer(
email: 'customer@example.com',
password: 'password123',
);
// Customer registration
final customer = await magento.createCustomer(
email: 'new@example.com',
password: 'password123',
firstName: 'John',
lastName: 'Doe',
);
// Get current customer
final currentCustomer = await magento.getCurrentCustomer();
// Logout
await magento.logout();
Products #
// Get products with filters
final products = await magento.getProducts(
page: 1,
pageSize: 20,
searchQuery: 'phone',
categoryId: '123',
sortBy: 'price',
sortOrder: 'asc',
filters: {'brand': 'Apple'},
);
// Get single product
final product = await magento.getProduct('SKU123');
// Search products
final searchResults = await magento.searchProducts(
'smartphone',
page: 1,
pageSize: 20,
);
// Get product reviews
final reviews = await magento.getProductReviews('SKU123');
Cart Management #
// Create cart
final cart = await magento.createCart();
// Add item to cart
final updatedCart = await magento.addToCart(
cartId: cart.id!,
sku: 'SKU123',
quantity: 2,
);
// Get cart totals
final totals = await magento.getCartTotals(cart.id!);
// Apply coupon
final cartWithCoupon = await magento.applyCoupon(
cartId: cart.id!,
couponCode: 'SAVE20',
);
// Estimate shipping
final shippingMethods = await magento.estimateShipping(
cartId: cart.id!,
address: shippingAddress,
);
Orders #
// Get customer orders
final orders = await magento.getCustomerOrders(
page: 1,
pageSize: 20,
);
// Get order details
final order = await magento.getOrder('ORDER123');
// Get order status
final status = await magento.getOrderStatus('ORDER123');
// Cancel order
final cancelled = await magento.cancelOrder(
'ORDER123',
reason: 'Changed mind',
);
// Reorder
final newCart = await magento.reorder('ORDER123');
Wishlist #
// Get wishlist
final wishlist = await magento.getWishlist();
// Add to wishlist
final wishlistItem = await magento.addToDefaultWishlist(
productId: '123',
);
// Remove from wishlist
final removed = await magento.removeFromDefaultWishlist(1);
// Share wishlist
final shared = await magento.shareDefaultWishlist(
email: 'friend@example.com',
message: 'Check out my wishlist!',
);
// Add all to cart
final addedToCart = await magento.addAllDefaultWishlistToCart();
Advanced Search #
// Advanced search
final searchResults = await magento.search(
query: 'smartphone',
filters: {'brand': 'Apple', 'price': '100-500'},
page: 1,
pageSize: 20,
sortBy: 'price',
sortOrder: 'asc',
);
// Search by category
final categoryResults = await magento.searchByCategory(
categoryId: '123',
query: 'phone',
);
// Search by attribute
final attributeResults = await magento.searchByAttribute(
attribute: 'brand',
value: 'Apple',
);
// Get search suggestions
final suggestions = await magento.getSearchSuggestions('smart');
// Get filterable attributes
final attributes = await magento.getFilterableAttributes();
// Apply price filter
final priceFiltered = await magento.applyPriceFilter(
minPrice: 100.0,
maxPrice: 500.0,
);
ποΈ Architecture #
The plugin follows a clean architecture pattern with the following layers:
- API Layer: HTTP client with Dio, REST API integration
- Service Layer: Business logic and data processing
- Model Layer: Data models with JSON serialization
- Plugin Layer: Flutter plugin interface
Directory Structure #
lib/
βββ src/
β βββ api/ # API classes
β β βββ auth_api.dart
β β βββ product_api.dart
β β βββ cart_api.dart
β β βββ order_api.dart
β β βββ wishlist_api.dart
β β βββ search_api.dart
β βββ models/ # Data models
β β βββ auth_models.dart
β β βββ product_models.dart
β β βββ cart_models.dart
β β βββ order_models.dart
β β βββ wishlist_models.dart
β β βββ search_models.dart
β βββ flutter_magento_plugin.dart
βββ flutter_magento.dart
βββ flutter_magento_platform_interface.dart
π§ Configuration #
Environment Setup #
// Development
await magento.initialize(
baseUrl: 'https://dev-store.com',
connectionTimeout: 30000,
receiveTimeout: 30000,
);
// Production
await magento.initialize(
baseUrl: 'https://store.com',
headers: {
'X-API-Key': 'your-api-key',
'X-Store-Code': 'default',
},
);
Custom Headers #
await magento.initialize(
baseUrl: 'https://store.com',
headers: {
'Authorization': 'Bearer token',
'Accept-Language': 'en-US',
'X-Custom-Header': 'value',
},
);
π§ͺ Testing #
# Run tests
flutter test
# Run tests with coverage
flutter test --coverage
# Generate code
flutter packages pub run build_runner build --delete-conflicting-outputs
π± Platform Support #
- β Android
- β iOS
- β Web
- β Windows
- β macOS
- β Linux
π Security Features #
- JWT token authentication
- HTTPS enforcement
- Input validation and sanitization
- Secure token storage
- Rate limiting support
- CSRF protection
π Performance Features #
- Request caching
- Image optimization
- Lazy loading support
- Offline mode
- Background sync
- Memory management
π€ Contributing #
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
π License #
This project is licensed under the MIT License - see the LICENSE file for details.
π Support #
- π§ Email: support@nativemind.net
- π Issues: GitHub Issues
- π Documentation: Wiki
- π¬ Community: Discord
π Acknowledgments #
- Magento team for the excellent e-commerce platform
- Flutter team for the amazing framework
- ScandiPWA team for inspiration and best practices
- All contributors and community members
Made with β€οΈ by NativeMind Team