scan_to_pay 1.0.1 copy "scan_to_pay: ^1.0.1" to clipboard
scan_to_pay: ^1.0.1 copied to clipboard

Reusable Flutter SDK for scan-to-pay: OCR-based account-number capture, multi-frame confirmation, pluggable bank resolver, and themeable UI.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:scan_to_pay/scan_to_pay.dart';

void main() => runApp(const ScanToPayExampleApp());

class ScanToPayExampleApp extends StatelessWidget {
  const ScanToPayExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'scan_to_pay demo',
      theme: ThemeData(
        useMaterial3: true,
        colorSchemeSeed: const Color(0xFFD32F2F),
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  ScanResult? _lastResult;

  Future<void> _startScan() async {
    final result = await ScanToPayLauncher.push(
      context,
      config: ScanToPayConfig(
        theme: const ScanToPayTheme(
          accentColor: Color(0xFFD32F2F),
          title: 'Scan to Pay',
        ),
        onAccountResolved: (r) async {
          setState(() => _lastResult = r);
        },
      ),
    );
    if (result != null) setState(() => _lastResult = result);
  }

  @override
  Widget build(BuildContext context) {
    final result = _lastResult;
    return Scaffold(
      appBar: AppBar(title: const Text('scan_to_pay demo')),
      body: Padding(
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const Text(
              'Tap "Scan account" to open the SDK scanner, point the camera '
              'at a 10-digit NUBAN and tap Continue. The SDK returns a '
              'ScanResult to this app — everything after that is yours.',
            ),
            const SizedBox(height: 20),
            FilledButton.icon(
              onPressed: _startScan,
              icon: const Icon(Icons.qr_code_scanner),
              label: const Text('Scan account'),
            ),
            const SizedBox(height: 24),
            if (result != null) _ResultCard(result: result),
          ],
        ),
      ),
    );
  }
}

class _ResultCard extends StatelessWidget {
  const _ResultCard({required this.result});
  final ScanResult result;

  @override
  Widget build(BuildContext context) {
    return Card(
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('Account number',
                style: Theme.of(context).textTheme.labelMedium),
            Text(result.accountNumber,
                style: Theme.of(context).textTheme.headlineSmall),
            const SizedBox(height: 12),
            Text('Bank', style: Theme.of(context).textTheme.labelMedium),
            Text(result.bank?.name ?? 'Unknown'),
            const SizedBox(height: 12),
            Text('Confidence',
                style: Theme.of(context).textTheme.labelMedium),
            Text(result.confidence.toStringAsFixed(2)),
          ],
        ),
      ),
    );
  }
}
1
likes
160
points
12
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Reusable Flutter SDK for scan-to-pay: OCR-based account-number capture, multi-frame confirmation, pluggable bank resolver, and themeable UI.

Repository (GitHub)
View/report issues

Topics

#ocr #scan #payments #nuban #bank

License

MIT (license)

Dependencies

camera, flutter, google_mlkit_text_recognition, http, image_picker, meta, permission_handler

More

Packages that depend on scan_to_pay