Facebook Twitter Instagram
    DeepCrazyWorld
    Facebook Twitter Instagram Pinterest YouTube
    • FLUTTER
      • FLUTTER APP
        • QRCode
        • Quiz App
        • Chat GPT
        • PDF App
        • News App
        • Fitness App
        • Weather App
        • BMI Calculator
        • GAME APP
        • Ecommerce App
        • wallpaper App
        • Finance app
        • Chat App
        • Wallet App
        • Taxi App
        • Quran app
        • Music player app
      • FLUTTER UI
        • Splash Screen
        • Onboarding Screen
        • Login Screen
        • Card Design
        • Drawer
    • PROJECT
      • Android Projects
      • College Projects
      • FLUTTER APP
      • Project Ideas
      • PHP Projects
      • Python Projects
    • SOURCE CODE
    • ANDROID
      • ANDROID APP
      • GAME APP
      • ANDROID STUDIO
    • MCQ
      • AKTU MCQ
        • RPA MCQ
        • COA MCQ
        • HPC MCQ
        • SPM MCQ
        • Renewable Energy All MCQ
        • Data Compression MCQ
        • Data Structure MCQ
        • Digital Image Processing MCQ
        • Software Engineering MCQ
        • Machine Learning MCQ
        • Artificial Intelligence MCQ
      • D PHARMA MCQ
        • Pharmaceutics – I MCQ
        • Pharmacognosy MCQ
        • Pharmaceutical Chemistry MCQ
        • Biochemistry and Clinical Pathology MCQ
        • Human Anatomy and Physiology MCQ
        • Heath Education and Community Pharmacy MCQ
    • INTERVIEW QUESTIONS
      • Flutter Interview Questions
      • INTERVIEW QUESTIONS
      • Python Interview Questions
      • Coding ninjas solution
    • MORE
      • WORDPRESS
        • SEO
        • TOP 10 WORDPRESS THEME
      • PRODUCTIVITY
      • Program
      • QUOTES
    DeepCrazyWorld
    Home»FLUTTER APP»How to make QR Scanner app in Flutter with Source Code Step by step
    FLUTTER APP

    How to make QR Scanner app in Flutter with Source Code Step by step

    DeepikaBy DeepikaAugust 19, 2024Updated:August 19, 2024No Comments4 Mins Read

    Creating a QR Scanner app in Flutter involves several steps, including setting up your development environment, creating a new Flutter project, adding dependencies, writing the code, and testing the app. Below is a step-by-step guide to help you build a simple QR Scanner app.

    Table of Contents

    Toggle
    • Step 1: Set Up Your Development Environment
    • Step 2: Create a New Flutter Project
    • Step 3: Add Dependencies
    • Step 4: Create the User Interface
    • Step 5: Run the App
    • Step 6: Testing the App
    • Step 7: (Optional) Customize the App
    • OUTPUT
    • Source Code
    • Related Articles:

    Step 1: Set Up Your Development Environment

    1. Install Flutter: Follow the Flutter installation guide to set up Flutter on your machine.
    2. Set Up an Editor: Install Visual Studio Code, Android Studio, or any other preferred IDE. Install Flutter and Dart plugins for your editor.

    Step 2: Create a New Flutter Project

    1. Open your terminal or command prompt.
    2. Run the following command to create a new Flutter project:
       flutter create qr_scanner
    1. Navigate to the project directory:
       cd qr_scanner

    Step 3: Add Dependencies

    1. Open the pubspec.yaml file in the root of your project.
    2. Add the qr_code_scanner package to the dependencies section:
       dependencies:
         flutter:
           sdk: flutter
         qr_code_scanner: ^1.0.0
    1. Save the file and run the following command to install the package:
       flutter pub get

    Step 4: Create the User Interface

    1. Open the lib/main.dart file.
    2. Replace its contents with the following code to create the basic structure of the app:
       import 'package:flutter/material.dart';
       import 'package:qr_code_scanner/qr_code_scanner.dart';
    
       void main() => runApp(MyApp());
    
       class MyApp extends StatelessWidget {
         @override
         Widget build(BuildContext context) {
           return MaterialApp(
             title: 'QR Scanner',
             theme: ThemeData(
               primarySwatch: Colors.blue,
             ),
             home: QRViewExample(),
           );
         }
       }
    
       class QRViewExample extends StatefulWidget {
         @override
         _QRViewExampleState createState() => _QRViewExampleState();
       }
    
       class _QRViewExampleState extends State<QRViewExample> {
         final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
         Barcode? result;
         QRViewController? controller;
    
         @override
         Widget build(BuildContext context) {
           return Scaffold(
             appBar: AppBar(
               title: Text('QR Scanner'),
             ),
             body: Column(
               children: <Widget>[
                 Expanded(
                   flex: 5,
                   child: QRView(
                     key: qrKey,
                     onQRViewCreated: _onQRViewCreated,
                   ),
                 ),
                 Expanded(
                   flex: 1,
                   child: Center(
                     child: (result != null)
                         ? Text('Barcode Type: ${result!.format}   Data: ${result!.code}')
                         : Text('Scan a code'),
                   ),
                 )
               ],
             ),
           );
         }
    
         void _onQRViewCreated(QRViewController controller) {
           setState(() {
             this.controller = controller;
           });
           controller.scannedDataStream.listen((scanData) {
             setState(() {
               result = scanData;
             });
           });
         }
    
         @override
         void dispose() {
           controller?.dispose();
           super.dispose();
         }
       }

    Step 5: Run the App

    1. Ensure that your device or emulator is running.
    2. Run the following command to start the app:
       flutter run
    1. The app should open with a camera view to scan QR codes. Once a QR code is detected, the app will display the type of barcode and the data contained in it.

    Step 6: Testing the App

    1. Test the app by scanning various QR codes.
    2. Ensure that the app correctly displays the scanned data.

    Step 7: (Optional) Customize the App

    • Customize the UI by modifying the widgets in the QRViewExample class.
    • Handle different QR code formats and add features like storing scan history, sharing scanned data, or triggering actions based on the QR code content.

    OUTPUT

    Source Code

    You can copy the code provided above directly into your Flutter project to create a basic QR Scanner app.

    If you have any issues or need further customization, feel free to ask!

    Related Articles:

    • Creating a Ludo app in Flutter with Source Code Step by step
    • How to make Ludo app in Flutter with Source Code Step by step
    • How to make PDF Reader app in Flutter with Source Code Step by step
    • How to Make a ToDo App with Flutter with source Code StepWise in 2024
    • What is package in Flutter (Dart) with example in 2024
    • What is class in Flutter(Dart) with example step by step
    • Advantage of Flutter with examples in 2024
    • Top 15 Amazing Applications Built with Flutter Framework
    • Specialized PDF reader designed specifically for music sheets
    • Flutter File Integrity Checker app for checking integrity of a file
    • Christmas Quote Generator app built with flutter source code
    • Create fast food orders and bundle it up into a QR code with flutter

    Share. Facebook Twitter LinkedIn WhatsApp Telegram Pinterest Reddit Email
    Previous ArticleHow to Make a ToDo App with Flutter with source Code StepWise in 2024
    Next Article How to make PDF Reader app in Flutter with Source Code Step by step

    Related Posts

    How to make Diary App using flutter stepwise using getx

    FLUTTER APP 4 Mins Read

    How to Create Music Player UI screen with fully functional in flutter

    FLUTTER APP 3 Mins Read

    How to make Heart rate measure app with Flutter stepwise

    FLUTTER APP 5 Mins Read

    How to make ChatGpt App in flutter with source code Stepwise

    Chat GPT 5 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile March 29, 2025
    • Creating an Instruction UI Screen in Flutter Application March 29, 2025
    • Animated Backgrounds in Flutter: A Complete Guide March 15, 2025
    • How to make Diary App using flutter stepwise using getx August 31, 2024
    • How to Create Music Player UI screen with fully functional in flutter August 30, 2024
    • How to make ListView Builder Ui in flutter with Source Code August 29, 2024
    • Create a TabBar View in flutter with fully functional stepwise August 28, 2024
    • How to create TabBar view in flutter with source code step wise August 27, 2024
    • How to make Heart rate measure app with Flutter stepwise August 26, 2024
    • How to make ChatGpt App in flutter with source code Stepwise August 25, 2024
    Facebook Twitter Instagram Pinterest YouTube
    • About
    • Contact
    • Disclaimer
    • Privacy Policy
    Copyright by DeepCrazyWorld © 2025

    Type above and press Enter to search. Press Esc to cancel.