Below is a complete step-by-step guide to create a QR Code Scanner App using Flutter, suitable for beginners and also good enough for a production-ready demo πŸš€
(I’ll keep it simple and clean, just like your previous Flutter learning topics.)


πŸ”Ή Step 1: Create a New Flutter Project

flutter create qr_scanner_app
cd qr_scanner_app
flutter run

πŸ”Ή Step 2: Add Required Dependencies

Open pubspec.yaml and add:

dependencies:
  flutter:
    sdk: flutter
  mobile_scanner: ^5.0.0

Then run:

flutter pub get

πŸ‘‰ mobile_scanner is fast, stable, and supports Android & iOS.


πŸ”Ή Step 3: Android Permissions

πŸ“Œ AndroidManifest.xml

android/app/src/main/AndroidManifest.xml

<uses-permission android:name="android.permission.CAMERA"/>

Inside <application> tag:

android:hardwareAccelerated="true"

πŸ”Ή Step 4: iOS Permissions

πŸ“Œ Info.plist

ios/Runner/Info.plist

<key>NSCameraUsageDescription</key>
<string>Camera permission is required to scan QR codes</string>

πŸ”Ή Step 5: Main App Code

πŸ“Œ main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'QR Scanner',
      home: const QRScannerPage(),
    );
  }
}

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

  @override
  State<QRScannerPage> createState() => _QRScannerPageState();
}

class _QRScannerPageState extends State<QRScannerPage> {
  String scannedResult = "Scan a QR Code";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("QR Scanner App"),
        centerTitle: true,
      ),
      body: Column(
        children: [
          Expanded(
            flex: 4,
            child: MobileScanner(
              onDetect: (barcode) {
                final String? code = barcode.barcodes.first.rawValue;
                if (code != null) {
                  setState(() {
                    scannedResult = code;
                  });
                }
              },
            ),
          ),
          Expanded(
            flex: 1,
            child: Container(
              width: double.infinity,
              color: Colors.black,
              alignment: Alignment.center,
              child: Text(
                scannedResult,
                style: const TextStyle(
                  color: Colors.white,
                  fontSize: 16,
                ),
                textAlign: TextAlign.center,
              ),
            ),
          ),
        ],
      ),
    );
  }
}

πŸ”Ή Step 6: Run the App

flutter run

πŸ“± Point your camera at any QR code β†’ result appears instantly.


πŸ”Ή Features You Can Add (Next Level πŸš€)

βœ” Flashlight ON/OFF
βœ” Scan only once (prevent duplicate scans)
βœ” Open scanned URL in browser
βœ” Save scanned history
βœ” Add Clean Architecture + BLoC (like your previous projects)


πŸ”Ή Flashlight Button Example (Optional)

MobileScannerController controller = MobileScannerController();
IconButton(
  icon: const Icon(Icons.flash_on),
  onPressed: () {
    controller.toggleTorch();
  },
),

πŸ”Ή Common Errors & Fixes

❌ Camera not opening
βœ” Check permissions in AndroidManifest & Info.plist

❌ App crashes on scan
βœ” Use null check for barcode value


πŸ”Ή Final Output

βœ” Fast QR scanning
βœ” Android & iOS supported
βœ” Minimal & clean UI
βœ” Production ready base

Categories: Flutter

1 Comment

  • Elite Quiz - Trivia Quiz | Quiz Game - Flutter Full App + Admin Panel - Dheeraj Hitech · December 29, 2025 at 2:52 pm

    […] Also Read :- How to create QR Scanner App Using Flutter […]

    Leave a Reply

    Avatar placeholder

    Your email address will not be published. Required fields are marked *