luxo_client

pub package License

Dart/Flutter SDK for Luxo — a schema-driven API framework with compile-time field selection.

Features

  • HTTP/2 Transport with JSON and binary modes
  • WebSocket with auto-reconnect (exponential backoff)
  • Binary Codec — varint/svarint/fixed64 encoding, zero-copy field masks
  • 401 Auto-Refresh — token expiry callback with automatic retry
  • Timeout Support — configurable request timeout
  • Code Generation — generate typed client from schema introspection
  • AST Field Tracking — compile-time $select injection via package:analyzer
  • Nested Relations — deep field tracking with depth warnings

Install

dependencies:
  luxo_client: ^0.1.0

Quick Start

import 'package:luxo_client/luxo_client.dart';

// Create transport
final transport = HttpTransport(
  'http://localhost:4000/luvia',
  token: 'your-jwt-token',
);

// Make API calls
final result = await transport.call('getUser', {'id': 1});

Code Generation

Generate a typed client from your running Luxo service:

dart run luxo_client:generate \
  --endpoint http://localhost:4000/luvia \
  --key YOUR_INTROSPECTION_KEY \
  --out lib/src/luxo

This generates:

  • types.dart — typed model classes with binary decoders
  • schema.dart — API schema map for binary transport
  • client.dart — typed client with methods per API
import 'package:your_app/src/luxo/client.dart';

final client = LuxoClient.create(
  'http://localhost:4000/luvia',
  token: 'your-jwt-token',
);

final user = await client.getUser(1);
print(user.name);

final posts = await client.listPosts(page: 1, pageSize: 20);

WebSocket

final ws = WsTransport(
  'ws://localhost:4000/ws',
  token: 'your-jwt-token',
  autoReconnect: true, // exponential backoff: 1s, 2s, 4s... max 30s
);

ws.onMessage = (data) {
  print('Received: $data');
};

await ws.connect();

Binary Mode

Switch to binary protocol for production (smaller payloads, faster parsing):

final transport = HttpTransport(
  'http://localhost:4000/luvia',
  mode: TransportMode.binary,
);

Field Tracking (Build Runner)

Automatically detect which fields your code accesses and inject $select:

# build.yaml
targets:
  $default:
    builders:
      luxo_client|select_hints:
        enabled: true
dart run build_runner build

Libraries

luxo_client
Luxo client SDK for Dart / Flutter.