qr_flow_sdk 0.2.1
qr_flow_sdk: ^0.2.1 copied to clipboard
Flutter SDK for the QR Flow API. Generate static and dynamic QR codes with a single API key. Includes local payload generators, a CRUD service for API-backed dynamic QR codes, and a customizable QrFlo [...]
qr_flow_sdk #
A Flutter SDK for the QR Flow API — generate static and dynamic QR codes in your app with a single API key.
- Static QR — generated locally, no network call. Supports URL, text, WiFi, vCard, email, SMS, and phone.
- Dynamic QR — API-backed, with a stable redirect URL. Change the destination any time without reprinting.
- QrFlowImage widget — drop-in
Widgetthat renders any QR code with full color and shape customization.
Getting Started #
1. Obtain an API key #
Contact qr-flow.dev or your self-hosted admin dashboard to create a tenant and receive an API key (sk_live_...).
2. Add the dependency #
dependencies:
qr_flow_sdk: ^0.1.0
3. Initialize #
Call QrFlow.init once at app startup, before any other SDK call.
import 'package:qr_flow_sdk/qr_flow_sdk.dart';
void main() {
QrFlow.init(apiKey: 'sk_live_YOUR_KEY');
runApp(const MyApp());
}
Static QR Codes #
Static QR codes are generated entirely on-device — no network request is made.
// URL
final qr = QrFlow.staticQr.url('https://example.com');
// WiFi
final qr = QrFlow.staticQr.wifi(
ssid: 'MyNetwork',
password: 'secret',
encryption: 'WPA',
);
// Contact (vCard)
final qr = QrFlow.staticQr.contact(
firstName: 'Jane',
lastName: 'Doe',
phone: '+1234567890',
email: 'jane@example.com',
);
// Email
final qr = QrFlow.staticQr.email(
address: 'support@example.com',
subject: 'Hello',
);
// SMS
final qr = QrFlow.staticQr.sms(phone: '+1234567890', message: 'Hi!');
// Phone
final qr = QrFlow.staticQr.phone('+1234567890');
// Plain text
final qr = QrFlow.staticQr.text('Hello, World!');
Display it:
QrFlowImage(data: qr.payload, size: 220)
Register it with the API for quota tracking (optional):
final registered = await QrFlow.staticQr.register(qr);
print(registered.id); // server-assigned ID
Dynamic QR Codes #
Dynamic QR codes are managed by the API. The QR image encodes a stable redirect URL; you can update the destination at any time.
// Create
final qr = await QrFlow.dynamicQr.create(
name: 'Restaurant Menu',
targetUrl: 'https://restaurant.com/menu',
type: 'menu', // url | menu | event | custom
);
print(qr.redirectUrl); // encode THIS into the QR image
// Update destination (no reprint needed)
await QrFlow.dynamicQr.update(qr.id, targetUrl: 'https://restaurant.com/menu-v2');
// Toggle active/inactive
await QrFlow.dynamicQr.toggle(qr.id, isActive: false);
// List all
final list = await QrFlow.dynamicQr.list();
// Analytics (last 7 days)
final analytics = await QrFlow.dynamicQr.analytics(qr.id, days: 7);
print('${analytics.totalScans} scans, ${analytics.uniqueScans} unique');
// Delete
await QrFlow.dynamicQr.delete(qr.id);
Display a dynamic QR:
QrFlowImage.dynamic(qr: qr, size: 220)
QrFlowImage Widget #
// Static payload
QrFlowImage(
data: 'https://example.com',
size: 200,
style: const QrStyle(
foreground: '#1a1a2e',
background: '#ffffff',
shape: 'rounded', // 'square' | 'rounded'
),
)
// Dynamic QR — auto-encodes qr.redirectUrl
QrFlowImage.dynamic(qr: myDynamicQr, size: 200)
QrStyle #
| Field | Type | Default | Description |
|---|---|---|---|
foreground |
String |
'#000000' |
Module color (hex) |
background |
String |
'#FFFFFF' |
Background color (hex) |
shape |
String |
'square' |
'square' or 'rounded' modules |
Usage & Quota #
final usage = await QrFlow.usage();
print('Plan: ${usage.plan}');
print('Static: ${usage.staticUsed} / ${usage.staticLimit ?? "unlimited"}');
print('Dynamic: ${usage.dynamicUsed} / ${usage.dynamicLimit ?? "unlimited"}');
Plan Limits #
| Plan | Static QR / month | Dynamic QR (total) |
|---|---|---|
| Free | 100 | 5 |
| Pro | 10,000 | 100 |
| Enterprise | Unlimited | Unlimited |
Error Handling #
All API calls throw typed exceptions:
try {
final qr = await QrFlow.dynamicQr.create(
name: 'My QR',
targetUrl: 'https://example.com',
);
} on QrFlowQuotaException catch (e) {
print('Quota exceeded: ${e.current}/${e.limit}');
} on QrFlowAuthException {
print('Invalid API key');
} on QrFlowNotFoundException {
print('QR not found');
} on QrFlowValidationException catch (e) {
print('Validation error: ${e.message}');
} on QrFlowException catch (e) {
print('API error (${e.statusCode}): ${e.message}');
}
PayloadGenerator #
Use PayloadGenerator directly to build QR payload strings without creating a StaticQr:
final wifiString = PayloadGenerator.wifi(
ssid: 'Network',
password: 'pass',
encryption: 'WPA',
);
Advanced Configuration #
QrFlow.init(
apiKey: 'sk_live_xxx',
baseUrl: 'https://your-self-hosted-api.example.com',
timeout: const Duration(seconds: 15),
);