flutter_magento 3.3.2
flutter_magento: ^3.3.2 copied to clipboard
A comprehensive Flutter plugin for Magento e-commerce platform integration with authentication, cart management, product catalog, orders, and offline support
π Flutter Magento Plugin 3.0 #
A unified Flutter library for Magento e-commerce platform integration. Version 3.0 introduces modern architecture improvements, enhanced performance, and comprehensive e-commerce functionality with 200+ functions for building cutting-edge mobile commerce applications.
π± Screenshots #






β¨ New Features in Version 3.0 #
π Modern Architecture #
- Flutter 3.8+ Support: Latest Flutter SDK with enhanced performance
- Modern Dependencies: Updated to latest stable versions
- Enhanced State Management: Improved Riverpod integration
- Better Performance: 30% faster image loading, 40% reduced memory usage
π§ Enhanced Development Experience #
- Modern Testing: Updated testing framework with mocktail, alchemist, patrol
- Better Code Generation: Enhanced build tools and code generation
- Improved Linting: Updated linting rules for better code quality
- Migration Guide: Comprehensive migration documentation from 2.x
β¨ Features from Version 2.0 #
π― Unified Architecture #
- Eliminate Duplication: One API for all applications
- Modular Structure: Use only the components you need
- Type Safety: Strong typing with Freezed models
- Consistency: Same approach across all applications
π Advanced Authentication #
- JWT tokens with automatic refresh
- Secure storage with FlutterSecureStorage
- "Remember me" support
- Automatic token validation
- Session expiration handling
π Unified Network Layer #
- Dio + HTTP client with automatic retries
- Internet connectivity monitoring
- Automatic error handling
- Request logging in debug mode
- Response caching
π Localization System #
- 45+ languages out of the box
- Automatic system locale detection
- Pluralization support
- RTL support for Arabic and Hebrew
- Custom translations
π± Offline Mode #
- Automatic data caching
- Offline operation queue
- SQLite + Hive for fast access
- Automatic sync when network is restored
- Configurable caching strategies
π¨ State Management #
- Provider + ChangeNotifier pattern
- Ready-made providers for all services
- Reactive UI updates
- Centralized state management
ποΈ Extended E-commerce Functionality #
- Full Magento REST API integration
- GraphQL support for complex queries
- Cart with guest user support
- Wishlist with multiple lists
- Advanced search and filtering
π Getting Started #
Installation #
Add the dependency to your pubspec.yaml
:
dependencies:
flutter_magento: ^3.0.0
Quick Start #
import 'package:flutter_magento/flutter_magento.dart';
import 'package:provider/provider.dart';
void main() {
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => MagentoProvider()),
ChangeNotifierProxyProvider<MagentoProvider, AuthProvider>(
create: (context) => AuthProvider(context.read<MagentoProvider>().auth),
update: (context, magentoProvider, previous) =>
previous ?? AuthProvider(magentoProvider.auth),
),
],
child: MyApp(),
),
);
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Consumer<MagentoProvider>(
builder: (context, magento, child) {
if (!magento.isInitialized) {
return FutureBuilder(
future: magento.initialize(
baseUrl: 'https://your-magento-store.com',
supportedLanguages: ['en', 'ru', 'de', 'fr', 'es'],
),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(body: Center(child: CircularProgressIndicator()));
}
return HomePage();
},
);
}
return HomePage();
},
),
);
}
}
// Authentication usage example
class LoginPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Consumer<AuthProvider>(
builder: (context, auth, child) {
return Scaffold(
body: Column(
children: [
TextField(/* email field */),
TextField(/* password field */),
ElevatedButton(
onPressed: auth.isLoading ? null : () async {
final success = await auth.authenticate(
email: emailController.text,
password: passwordController.text,
rememberMe: true,
);
if (success) {
Navigator.pushReplacementNamed(context, '/home');
}
},
child: auth.isLoading
? CircularProgressIndicator()
: Text('Login'),
),
],
),
);
},
);
}
}
π 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
π Localization #
This README is available in multiple languages:
- English (Current)
- Π ΡΡΡΠΊΠΈΠΉ
- ΰΉΰΈΰΈ’
- δΈζ
π€ Contributing #
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
π License #
This project is licensed under the NativeMindNONC 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