Linkit
SDK Reference

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 linkit
dependencies:
  linkit: ^0.1.0

Quick 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

ServiceMethodsDescription
client.skuscreate(), getById(), update(), updateStock(), deleteById(), list()Per-branch inventory
client.productscreate(), getById(), update(), deleteById(), list()Product catalog
client.branchescreate(), getById(), update(), deleteById(), list()Physical locations
client.customerscreate(), getById(), update(), deleteById(), list(), lookupByEmail(), lookupByPhone(), search(), createAddress(), updateAddress(), deleteAddress(), createGroup(), updateGroup(), deleteGroup()Customer profiles
client.ordersgetById(), list(), updateStatus()Order management
client.offerscreate(), getById(), update(), updateStatus(), deleteById(), list(), bulkUpsert()Promotions & discounts
client.brandscreate(), getById(), update(), deleteById(), list()Brand management
client.categoriescreate(), getById(), update(), deleteById(), list()Product categories
client.genericscreate(), getById(), update(), deleteById(), list()Generic entities
client.healthcheck(), ping()System health
client.integrationslist(), 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 error

Dart 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

ExceptionStatusDescription
LinkitExceptionBase exception
LinkitInitializationExceptionBad configuration
LinkitApiExceptionAnyAPI error response
LinkitAuthenticationException401Invalid credentials
LinkitAuthorizationException403Insufficient permissions
LinkitNotFoundException404Resource not found
LinkitValidationException400Validation failed
LinkitConflictException409State conflict
LinkitRateLimitException429Rate limit exceeded
LinkitServerException5xxServer-side error
LinkitSerializationExceptionJSON 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.