ao_bi 0.2.1 copy "ao_bi: ^0.2.1" to clipboard
ao_bi: ^0.2.1 copied to clipboard

Validate Angolan Identity Card

example/lib/main.dart

import 'package:ao_bi/ao_bi.dart';
import 'package:example/bi_data_view.dart';
import 'package:example/bottom_sheet_container.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        bottomSheetTheme: const BottomSheetThemeData(
            backgroundColor: Colors.white,
            modalBackgroundColor: Colors.white,
            surfaceTintColor: Colors.white),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Scanner'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');

  void shoResult(BIData? data) {
    if (data == null) return;
    showModalBottomSheet<dynamic>(
      context: context,
      showDragHandle: true,
      isScrollControlled: true,
      useRootNavigator: true,
      barrierColor: Colors.black38,
      backgroundColor: Colors.white,
      useSafeArea: true,
      builder: (ctx) => SheetContainer(
        height: MediaQuery.of(context).size.height * (3 / 4.5),
        child: BIDataView(data),
      ),
    );
  }

  void onScanner() async {
    BIUtil.scan(
      context: context,
      useRootNavigator: true,
      style: BIQrStyle(
          appBarBackgroundColor: Theme.of(context).colorScheme.inversePrimary,
          accentColor: Colors.white,
          labelStyle: const TextStyle(color: Colors.white)),
      title: "Scan my document",
    ).then(shoResult);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Container(
        padding: const EdgeInsets.all(30),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SizedBox(
              height: 50.0,
              child: ClipRRect(
                borderRadius: BorderRadius.circular(8.0),
                child: MaterialButton(
                  onPressed: onScanner,
                  color: Colors.deepPurple,
                  elevation: 0.0,
                  child: const SizedBox(
                    width: double.infinity,
                    height: 50.0,
                    child: Center(
                      child: Text(
                        "Scan",
                        style: TextStyle(color: Colors.white),
                      ),
                    ),
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
2
likes
140
points
16
downloads

Publisher

verified publisheredvaldomartins.dev

Weekly Downloads

Validate Angolan Identity Card

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, qr_code_scanner_plus

More

Packages that depend on ao_bi