Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Key Widgets
  • UI Components
  • Design & Animations
  • Forms & Gestures
  • Navigation & Routing
  • Flutter Interview Questions
  • Dart
  • Android
  • Kotlin
  • Kotlin Android
  • Android with Java
  • Android Studio
Open In App
Next Article:
FlashCards Learning App in Flutter
Next article icon

FlashCards Learning App in Flutter

Last Updated : 31 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The FlashCard learning app is the one-stop destination to create an interactive learning/quiz app. This app was developed using Flutter. Flutter is the tool used to build cross-platform applications for different platforms and OS. In this article, we will learn to develop a flashcard learning app. You may use this app for learning purposes, it presents the question and its answer using flips or tap options. It also has the feature to add a new flashcard with a question and answer of your choice. I am using VS code to develop this project.

FlashCard

Concepts Covered in the App

  • Flash Card Widget.
  • Logic to add new question and answer.
  • Update the state of different questions and answers.
  • Flippable animation.

Project Structure

Directory_Structure


Step-by-Step Implementation of Flashcard Learning App

Step 1 : Create a new Flutter Application

Create a new Flutter application using the command Prompt. To create a new app, write the below command and run it.

flutter create app_name

To know more about it refer this article: Creating a Simple Application in Flutter

Step 2 : Adding the Dependency

To add the dependency to the pubspec.yaml file, add flip_card as a dependency in the dependencies part of the pubspec.yaml file, as shown below:

Dart
dependencies:      flutter:        sdk: flutter      flip_card: ^0.7.0 

Now run the below command in the terminal.

flutter pub get

Or

Run the below command in the terminal.

flutter pub add flip_card


Step 3 : Code for flash_card.dart

We create a stateless widget using the Card class to display questions and answers in our learning app.

flash_card.dart:

flash_card.dart
import 'package:flutter/material.dart';  // Model class representing a flashcard // with a question and an answer class Flashcard {   final String question;   final String answer;    Flashcard({required this.question, required this.answer}); }  // Stateless widget to display a // flashcard with a given text class FlashCardWidget extends StatelessWidget {   FlashCardWidget({required this.text});   final String text;    @override   Widget build(BuildContext context) {     return Padding(       padding: EdgeInsets.all(20.0),       child: Card(         shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(35)),         elevation: 17,         shadowColor: Color.fromARGB(255, 2, 75, 6),         color: Colors.green[700],         child: Padding(           padding: const EdgeInsets.all(10.0),           child: Center(             child: Text(text,                 style: TextStyle(                     fontSize: 15,                     letterSpacing: 1.0,                     color: Colors.white,                     fontWeight: FontWeight.bold),                 textAlign: TextAlign.center),           ),         ),       ),     );   } } 


Step 4 : Code for ques_ans.dart file

We use the Flashcard widget to represent the question and answer. The two parameters of Flashcard will be question for front widget and answer for the back widget.

Note : The class Flashcard can be renamed as per your choice but the Flashcard given as parameter of List is widget which can't be renamed.

ques_ans.dart:

ques_ans.dart
// List of flashcards containing // questions and answers import 'package:geeks_for_geeks/flashCard.dart';  List<Flashcard> qaList = [   Flashcard(       question: "What is the building block of a Flutter app?",       answer: "Widget"),   Flashcard(       question: "What is State in Flutter?",       answer:           "State refers to the data or information that can change dynamically during the lifetime of a widget."),   Flashcard(       question: "What is the purpose of the Widget Inspector in Flutter?",       answer:           "It is a tool used to inspect and debug the widget tree of a Flutter app"),   Flashcard(       question: "What is a Stream in Flutter?",       answer:           "Stream is a sequence of asynchronous events that can be listened to and responded to."),   Flashcard(question: "Is Flutter Open Source or not?", answer: "Yes"), ]; 


Step 5 : Code for home_widget.dart

This file consists of the UI and logic of the app. The code organizes the app bar, the cards, the textfield to enter new questions and answers, and the icon button to update questions. The stateful widget allows flippable animation over the flashcard. The left and right arrow icon buttons calls the function to update the function to update the question. The "Add Flashcard" button navigates to the Q&A page, where you can enter a question and answer for a new flashcard.

home_widget.dart:

home_widget.dart
import 'package:flip_card/flip_card.dart'; import 'package:flutter/material.dart'; import 'package:geeks_for_geeks/AddFlashCardPage.dart'; import 'package:geeks_for_geeks/flashCard.dart'; import 'package:geeks_for_geeks/ques_ans.dart';  // Main HomePage widget that is stateful class HomePage extends StatefulWidget {   const HomePage({Key? key}) : super(key: key);    @override   _HomePageState createState() => _HomePageState(); }  class _HomePageState extends State<HomePage> {        // Index to track the current   // flashcard being displayed   int _curIndexNum = 0;    @override   Widget build(BuildContext context) {     return Scaffold(         backgroundColor: Colors.grey.shade100,         appBar: AppBar(                          // AppBar with title and styling             centerTitle: true,             title: Text("Flashcards Learning App",                 style: TextStyle(                   fontSize: 25,                   color: Colors.white,                 )),             backgroundColor: Colors.green[700],             toolbarHeight: 70,             elevation: 5,             shadowColor: Colors.green[700],             shape: RoundedRectangleBorder(                 borderRadius: BorderRadius.circular(20))),         body: Center(             child: Column(                 mainAxisAlignment: MainAxisAlignment.center,                 children: <Widget>[                                      // FlipCard widget to display the                 // front and back of a flashcard                 SizedBox(                   width: 300,                   height: 300,                   child: FlipCard(                       direction: FlipDirection.HORIZONTAL,                       front:                           FlashCardWidget(text: qaList[_curIndexNum].question),                       back:                           FlashCardWidget(text: qaList[_curIndexNum].answer))),                              // Text below the FlipCard               Text("Tap to view Answer", style: TextStyle(fontSize: 15)),                              // Row containing buttons to               // navigate between flashcards               Row(                 mainAxisAlignment: MainAxisAlignment.spaceAround,                 children: <Widget>[                                        // Button to show the previous flashcard                   ElevatedButton.icon(                       onPressed: () {                         showPreviousCard();                       },                       icon: Icon(                         Icons.arrow_left,                         size: 30,                         color: Color(0xFFE4E4E4),                       ),                       label: Text(""),                       style: ElevatedButton.styleFrom(                           backgroundColor: Colors.green[700],                           shape: RoundedRectangleBorder(                               borderRadius: BorderRadius.circular(10)),                           padding: EdgeInsets.only(                               right: 20, left: 25, top: 15, bottom: 15))),                                      // Button to show the next flashcard                   ElevatedButton.icon(                       onPressed: () {                         showNextCard();                       },                       icon: Icon(                         Icons.arrow_right,                         size: 30,                         color: Color(0xFFE4E4E4),                       ),                       label: Text(""),                       style: ElevatedButton.styleFrom(                           backgroundColor: Colors.green[700],                           shape: RoundedRectangleBorder(                               borderRadius: BorderRadius.circular(10)),                           padding: EdgeInsets.only(                               right: 20, left: 25, top: 15, bottom: 15)))                 ],               ),               SizedBox(height: 15),                              // Button to navigate to the AddFlashcardPage               ElevatedButton(                   onPressed: () {                     Navigator.push(                         context,                         MaterialPageRoute(                             builder: (context) => AddFlashcardPage()));                   },                   child: Text(                     "Add FlashCard",                     style: TextStyle(                         fontSize: 10,                         letterSpacing: 1.0,                         fontWeight: FontWeight.bold,                         color: Colors.white),                     textAlign: TextAlign.center,                   ),                   style: ElevatedButton.styleFrom(                       backgroundColor: Colors.green[700],                       shape: RoundedRectangleBorder(                           borderRadius: BorderRadius.circular(10)),                       padding: EdgeInsets.only(                           right: 20, left: 25, top: 15, bottom: 15))),             ])));   }    // Function to show the next flashcard   void showNextCard() {     setState(() {       _curIndexNum = (_curIndexNum + 1 < qaList.length) ? _curIndexNum + 1 : 0;     });   }    // Function to show the previous flashcard   void showPreviousCard() {     setState(() {       _curIndexNum =           (_curIndexNum - 1 >= 0) ? _curIndexNum - 1 : qaList.length - 1;     });   } } 


Step 6 : Code for main.dart

The file is starting the app, and it calls the HomePage widget coded in above home_widget.dart.

main.dart:

main.dart
import 'package:flashcards_learning_app/home_widget.dart'; import 'package:flutter/material.dart';  void main() => runApp(MyApp());  class MyApp extends StatelessWidget {   @override   Widget build(BuildContext context) {     return MaterialApp(         debugShowCheckedModeBanner: false,         title: 'Flashcards Learning App',         home: HomePage());   } } 


Step 7 : Code for add_flash_card.dart

This is the logic to enter the question and answer and then update it in a new flash card.

add_flash_card.dart:

add_flash_card.dart
import 'package:flutter/material.dart'; import 'package:geeks_for_geeks/flashCard.dart'; import 'package:geeks_for_geeks/ques_ans.dart';  // This is the main StatefulWidget // for the AddFlashcardPage class AddFlashcardPage extends StatefulWidget {   @override   _AddFlashcardPageState createState() => _AddFlashcardPageState(); }  // This is the state class for // AddFlashcardPage class _AddFlashcardPageState extends State<AddFlashcardPage> {      // Controllers to manage the input   // for question and answer fields   final _questionController = TextEditingController();   final _answerController = TextEditingController();    // Function to add a new flashcard to the list   void _addFlashcard() {            // Check if both question and     // answer fields are not empty     if (_questionController.text.isNotEmpty &&         _answerController.text.isNotEmpty) {       setState(() {                    // Add the new flashcard to the qaList         qaList.add(Flashcard(           question: _questionController.text,           answer: _answerController.text,         ));       });        // Clear the input fields after       // adding the flashcard       _questionController.clear();       _answerController.clear();        // Navigate back to the previous screen       Navigator.pop(context);     }   }    @override   Widget build(BuildContext context) {     return Scaffold(       appBar: AppBar(         // Title for the app bar         title: Text("Enter the Question and Answer of your choice"),         backgroundColor: Colors.green,         foregroundColor: Colors.white,       ),       body: Padding(         padding: const EdgeInsets.all(20.0),         child: Column(           children: [             // TextField for entering the question             TextField(               controller: _questionController,               decoration: InputDecoration(                 labelText: 'Enter Question',               ),             ),             // TextField for entering the answer             TextField(               controller: _answerController,               decoration: InputDecoration(                 labelText: 'Enter Answer',               ),             ),             SizedBox(height: 20),             // Button to trigger the _addFlashcard function             ElevatedButton(               style: ElevatedButton.styleFrom(                 backgroundColor: Colors.green,                 foregroundColor: Colors.white,               ),               onPressed: _addFlashcard,               child: Text("Add Flashcard"),             ),           ],         ),       ),     );   } } 


Step 9 : Run the application

Save the project and enter the below command to run the application.

flutter run

Click here to get the Full Application Code Access

Output:


Next Article
FlashCards Learning App in Flutter

F

flutterfly
Improve
Article Tags :
  • Flutter
  • Flutter
  • Flutter Projects

Similar Reads

    Flutter - Build Language Learning App
    In this article, we will explore how to create a language-learning app using Flutter, a popular open-source UI software development toolkit developed by Google. Flutter enables developers to build natively compiled applications for mobile, web, and desktop platforms from a single codebase. This make
    13 min read
    Basic Quiz App In Flutter
    Flutter SDK is an open-source software development kit for building beautiful UI that is natively compiled. Currently, it is available as a stable version for iOS and Android OS. In this app, we are going to have the features or modules mentioned below:Five multiple-choice questions ( more questions
    8 min read
    Fitness App using Flutter
    The Fitness app is an essential companion for fitness enthusiasts who want to keep track of their exercises. In this article, we will learn how to build a Fitness App using Flutter for mobile devices. The app features a list of common exercises, allowing users to start and record the time spent on e
    10 min read
    Simple Age Calculator App using Flutter
    Flutter SDK is an open-source software development kit for building beautiful UI which is natively compiled. In this article, we'll build a simple Flutter app that calculates a person's age based on their birthdate. To do this, we'll need to take input from the user, perform the calculations, and di
    3 min read
    Video Streaming App in Flutter
    Designing a video streaming app is a fun task to improve your development skills and design fun applications. Using Flutter, an open-source UI toolkit developed by Google, you can design for apps in iOS and Android, web and desktop all at once. Here, in this article, the reader will be introduced to
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences