truthinscanner 0.0.1-dev.1 copy "truthinscanner: ^0.0.1-dev.1" to clipboard
truthinscanner: ^0.0.1-dev.1 copied to clipboard

A Flutter package for barcode scanning with TruthIn product database integration. Supports multiple barcode formats and provides real-time product information.

example/lib/main.dart

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize TruthInScanner with your API key
  // This must be called before using any scanner functionality
  TruthInScanner.initialize(
    apiKey: '6a688f744a2323d62bb74002a1e8ede4a8393ee1', // Replace with your API key
    // baseUrl: 'https://your-custom-api-url.com/', // Optional: custom base URL
  );

  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: 'Truthin Scanner',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Truthin Scanner'),
    );
  }
}

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

  final String title;

  void _navigateToScanner(BuildContext context) {
    Navigator.of(context).push(
      MaterialPageRoute(builder: (context) => const BarcodeScannerView()),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(title),
        centerTitle: true,
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 40.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Icon(
                Icons.qr_code_scanner,
                size: 100,
                color: Colors.blue,
              ),
              const SizedBox(height: 40),
              const Text(
                'Welcome to Truthin Scanner',
                style: TextStyle(
                  fontSize: 24,
                  fontWeight: FontWeight.bold,
                ),
                textAlign: TextAlign.center,
              ),
              const SizedBox(height: 60),
              // Button 1: Scan Barcode
              SizedBox(
                width: double.infinity,
                height: 56,
                child: ElevatedButton.icon(
                  onPressed: () => _navigateToScanner(context),
                  icon: const Icon(Icons.qr_code_scanner, size: 24),
                  label: const Text(
                    'Scan Barcode',
                    style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
                  ),
                  style: ElevatedButton.styleFrom(
                    backgroundColor: Colors.blue,
                    foregroundColor: Colors.white,
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(16),
                    ),
                    elevation: 2,
                  ),
                ),
              ),
 ],
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
80
downloads

Publisher

verified publishernatfirst.com

Weekly Downloads

A Flutter package for barcode scanning with TruthIn product database integration. Supports multiple barcode formats and provides real-time product information.

Homepage

License

unknown (license)

Dependencies

auto_size_text, camera, dio, flutter, flutter_svg, font_awesome_flutter, google_mlkit_barcode_scanning, google_mlkit_commons, permission_handler, pretty_dio_logger, shimmer, url_launcher, visibility_detector

More

Packages that depend on truthinscanner