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
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 […]