Skip to main content

embossed_card_scanner 1.0.0 copy "embossed_card_scanner: ^1.0.0" to clipboard
embossed_card_scanner: ^1.0.0 copied to clipboard

Reads embossed payment card numbers on device with a small CNN. Headless API for photos and your own frame streams, plus a ready camera widget with a torch.

example/lib/main.dart

import 'package:embossed_card_scanner/embossed_card_scanner.dart';
import 'package:material_ui/material_ui.dart';

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

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

  @override
  Widget build(BuildContext context) => MaterialApp(
    title: 'Embossed card scanner',
    theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.teal)),
    home: const HomePage(),
  );
}

/// A scan button and the scanned number below it.
class HomePage extends StatefulWidget {
  const HomePage({super.key});

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

class _HomePageState extends State<HomePage> {
  final _number = TextEditingController();

  @override
  void dispose() {
    _number.dispose();
    super.dispose();
  }

  Future<void> _scan() async {
    final result = await Navigator.of(
      context,
    ).push<CardScanResult>(MaterialPageRoute(builder: (_) => const ScanPage()));
    if (result != null) _number.text = result.formatted;
  }

  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(title: const Text('Embossed card scanner')),
    body: Padding(
      padding: const EdgeInsets.all(24),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          FilledButton.icon(
            key: const Key('scan'),
            onPressed: _scan,
            icon: const Icon(Icons.credit_card),
            label: const Text('Scan card'),
          ),
          const SizedBox(height: 24),
          TextField(
            key: const Key('number'),
            controller: _number,
            readOnly: true,
            style: const TextStyle(fontFamily: 'monospace', fontSize: 20),
            decoration: const InputDecoration(
              labelText: 'Card number',
              border: OutlineInputBorder(),
            ),
          ),
        ],
      ),
    ),
  );
}

/// Full-screen scanner: back button, torch and card frame are built in.
/// Pops with the result once a number is confirmed.
class ScanPage extends StatelessWidget {
  const ScanPage({super.key});

  @override
  Widget build(BuildContext context) => Scaffold(
    backgroundColor: Colors.black,
    body: CardScannerView(
      onResult: (result) => Navigator.of(context).pop(result),
    ),
  );
}
1
likes
160
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Reads embossed payment card numbers on device with a small CNN. Headless API for photos and your own frame streams, plus a ready camera widget with a torch.

Repository (GitHub)
View/report issues

Topics

#credit-card #scanner #camera #ocr #tflite

License

MIT (license)

Dependencies

camera, flutter, image, material_ui, meta, tflite_flutter

More

Packages that depend on embossed_card_scanner