Dart / Flutter SDK
Ultra high-performance Dart SDK for the Linkit API — Flutter-ready, dio-based, zero reflection, pub.dev distribution.
Dart / Flutter SDK
Package
linkit · Dart 3+ / Flutter 3+ · dio · Hand-written JSON (zero reflection) · pub.dev
Installation
dart pub add linkit
# or
flutter pub add linkitdependencies:
linkit: ^0.1.0Quick Start
Initialize the Client
import 'package:linkit/linkit.dart';
final client = LinkitClient.quickSetup('https://linkit.works/api/v1', 'your-jwt-token');Create a SKU
final sku = await client.skus.create(
(SkuCreateBuilder()
..withIvId('SKU-001')
..inBranch('BR-RYD')
..forProduct('PROD-001')
..withPrice(29.99)
..withQty(500))
.build(),
);
print('Created: ${sku.ivId}');Health Check
final health = await client.health.check();
print('Status: ${health.status}');
print('Version: ${health.version}');
for (final svc in health.services) {
print(' ${svc.name}: ${svc.status} (${svc.latencyMs}ms)');
}Clean Up
client.dispose();Configuration
final client = LinkitClient.create(const LinkitConfiguration(
baseUrl: 'https://linkit.works/api/v1',
jwtToken: 'your-jwt-token',
timeoutMs: 30000,
maxRetries: 3,
retryBaseDelayMs: 1000,
retryMaxDelayMs: 30000,
circuitBreakerThreshold: 5,
circuitBreakerRecoveryMs: 60000,
maxConcurrentRequests: 10,
));Services Reference
| Service | Methods | Description |
|---|---|---|
client.skus | create(), getById(), update(), updateStock(), deleteById(), list() | Per-branch inventory |
client.products | create(), getById(), update(), deleteById(), list() | Product catalog |
client.branches | create(), getById(), update(), deleteById(), list() | Physical locations |
client.customers | create(), getById(), update(), deleteById(), list(), lookupByEmail(), lookupByPhone(), search(), createAddress(), updateAddress(), deleteAddress(), createGroup(), updateGroup(), deleteGroup() | Customer profiles |
client.orders | getById(), list(), updateStatus() | Order management |
client.offers | create(), getById(), update(), updateStatus(), deleteById(), list(), bulkUpsert() | Promotions & discounts |
client.brands | create(), getById(), update(), deleteById(), list() | Brand management |
client.categories | create(), getById(), update(), deleteById(), list() | Product categories |
client.generics | create(), getById(), update(), deleteById(), list() | Generic entities |
client.health | check(), ping() | System health |
client.integrations | list(), getById(), execute(), enable(), disable() | Platform connections |
Builders
SkuCreateBuilder
final request = (SkuCreateBuilder()
..withIvId('SKU-001')
..inBranch('BR-RYD')
..forProduct('PROD-001')
..withBarcode('5901234123457')
..withPrice(29.99)
..withQty(500)
..withAvailable(true)
..withAmazonSku('AMZ-W001'))
.build(); // throws LinkitValidationException on errorDart Cascade Syntax
The Dart SDK uses Dart's cascade notation (..) for builder chaining. This is idiomatic Dart and equivalent to .method() chaining in other languages.
ProductCreateBuilder
final request = (ProductCreateBuilder()
..withIvId('PROD-001')
..withNameEn('Premium Widget')
..withNameAr('ودجت فاخر')
..withAveragePrice(149.99)
..withEnabled(true))
.build();BranchCreateBuilder
final request = (BranchCreateBuilder()
..withIvId('BR-RYD')
..withNameEn('Riyadh Main Store')
..withNameAr('متجر الرياض الرئيسي')
..withLocation(24.7136, 46.6753)
..withStatus(BranchStatus.published))
.build();Error Handling
try {
final sku = await client.skus.getById('nonexistent');
} on LinkitNotFoundException catch (e) {
print('Not found: ${e.resourceType}');
} on LinkitRateLimitException catch (e) {
print('Rate limited — retry after ${e.retryAfterMs}ms');
} on LinkitValidationException catch (e) {
for (final error in e.validationErrors) {
print(' ${error.field}: ${error.message}');
}
} on LinkitApiException catch (e) {
print('API error ${e.statusCode}: ${e.userFriendlyMessage}');
}Exception Hierarchy
| Exception | Status | Description |
|---|---|---|
LinkitException | — | Base exception |
LinkitInitializationException | — | Bad configuration |
LinkitApiException | Any | API error response |
LinkitAuthenticationException | 401 | Invalid credentials |
LinkitAuthorizationException | 403 | Insufficient permissions |
LinkitNotFoundException | 404 | Resource not found |
LinkitValidationException | 400 | Validation failed |
LinkitConflictException | 409 | State conflict |
LinkitRateLimitException | 429 | Rate limit exceeded |
LinkitServerException | 5xx | Server-side error |
LinkitSerializationException | — | JSON parse failure |
Flutter Integration
Flutter-Ready
The SDK has zero dependency on dart:mirrors or build_runner. It works in all Flutter targets: iOS, Android, Web, macOS, Windows, Linux. No code generation step required.
// In your Flutter widget
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
final client = LinkitClient.quickSetup('https://linkit.works/api/v1', 'token');
@override
void dispose() {
client.dispose();
super.dispose();
}
Future<void> _loadProducts() async {
final products = await client.products.list();
setState(() { /* update UI */ });
}
}Performance
dio HTTP Client
Connection pooling, interceptors, request cancellation, and progress tracking built in.
Zero Reflection
Hand-written fromJson/toJson — no mirrors, no build_runner, no generated code. Fully tree-shakeable.
50 Tests / 0 Warnings
Strict analysis with prefer_const_constructors, sort_constructors_first, and all recommended lints enabled.