Skip to main content

Reachu Flutter SDK

A Dart/Flutter SDK to manage shopping carts, checkouts, discounts, markets, channels and payments using GraphQL. It is designed to be a simple and strongly typed client for ecommerce integrations.

pub.dev likes popularity

Why Choose Flutter + GraphQL?

  • Native Performance: Flutter's compiled-to-native approach ensures smooth 60fps experiences
  • Efficient Data Fetching: GraphQL allows you to request exactly the data you need
  • Beautiful UI: Flutter's widget system makes it easy to create stunning shopping interfaces
  • Real-time Updates: GraphQL subscriptions for live inventory and price updates
  • Cross-platform: Write once, deploy to both iOS and Android

📚 SDK Modules

The Flutter SDK includes comprehensive modules for all ecommerce operations:

  • 🛒 Cart → Create, update, delete carts and line items
  • 💳 Checkout → Manage checkout sessions and order processing
  • 💰 Payment → Integrations with Stripe, Klarna, Vipps
  • 🎯 Discount → Create, verify and manage discount codes
  • 🌍 Market → Query available markets and currencies
  • 📦 Channel → Products, categories, and purchase conditions

📦 Quick Installation

Add the SDK to your pubspec.yaml:

pubspec.yaml
dependencies:
reachu_flutter_sdk: ^1.0.0

Then run:

Terminal
dart pub get

🚀 Basic Usage

lib/main.dart
import 'package:reachu_flutter_sdk/reachu_flutter_sdk.dart';

// Initialize the client
final sdk = SdkClient(
baseUrl: 'https://graph-ql-dev.reachu.io',
apiKey: 'your-api-key', // Use "Bearer <TOKEN>" if required
);

// Create a cart
final cart = await sdk.cart.create(
customer_session_id: 'session-123',
currency: 'USD',
);

// Add items to cart
final updatedCart = await sdk.cart.addItem(
cart_id: cart.cartId,
line_items: {
'product_id': 123,
'quantity': 2,
'variant_id': 456,
},
);

// Create checkout
final checkout = await sdk.checkout.create(cartId: cart.cartId);

Documentation Structure

For production apps, initialize the SDK once and reuse it throughout your app:

lib/services/sdk_service.dart
import 'package:reachu_flutter_sdk/reachu_flutter_sdk.dart';

class SdkService {
static final SdkService _instance = SdkService._internal();
late final SdkClient sdk;

factory SdkService() => _instance;
SdkService._internal();

void init({required String baseUrl, required String apiKey}) {
sdk = SdkClient(baseUrl: baseUrl, apiKey: apiKey);
}
}
lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'services/sdk_service.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();

await dotenv.load(fileName: ".env");

SdkService().init(
baseUrl: dotenv.env['GRAPHQL_ENDPOINT']!,
apiKey: dotenv.env['API_KEY']!,
);

runApp(MyApp());
}

💡 Usage Examples

Payment Integration

Payment Example
// Create Stripe payment intent
final intent = await sdk.payment.createPaymentIntentStripe(
checkoutId: checkout.id,
);
print('Client Secret: ${intent['client_secret']}');

Discount Management

Discount Operations
// Get available discounts
final discounts = await sdk.discount.get();
print(discounts.map((d) => d.toJson()).toList());

Market & Channel Data

Data Operations
// Get available markets
final markets = await sdk.market.getAvailable();

// Get product categories
final categories = await sdk.channel.category.get();

// Get products with caching
final products = await sdk.channel.product.get(
currency: 'USD',
useCache: true,
);

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Ready to build amazing Flutter shopping experiences?