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 Diary App using flutter stepwise using getx
    FLUTTER APP

    How to make Diary App using flutter stepwise using getx

    DeepikaBy DeepikaAugust 31, 2024Updated:March 29, 2025No Comments4 Mins Read

    Creating a Diary App using Flutter with GetX involves several steps. Here’s a step-by-step guide to get you started:

    Table of Contents

    Toggle
    • Step 1: Setup Your Flutter Project
    • Step 2: Define Your Data Model
    • Step 3: Create the GetX Controller
    • Step 4: Build the UI
    • Step 5: Set Up Main Entry Point
    • Step 6: Testing
    • Output
    • Related Articles

    Step 1: Setup Your Flutter Project

    1. Create a New Flutter Project:
       flutter create diary_app
       cd diary_app
    1. Add Dependencies:
      Open pubspec.yaml and add get for state management and other necessary dependencies.
       dependencies:
         flutter:
           sdk: flutter
         get: ^4.6.5
         flutter_local_notifications: ^15.0.0

    Then run:

       flutter pub get

    Step 2: Define Your Data Model

    Create a model class to represent a diary entry. For simplicity, let’s assume each entry has a title and content.

    1. Create a models directory and a file diary_entry.dart:
       // lib/models/diary_entry.dart
       class DiaryEntry {
         String title;
         String content;
    
         DiaryEntry({required this.title, required this.content});
    
         // Convert a DiaryEntry into a Map
         Map<String, dynamic> toMap() {
           return {
             'title': title,
             'content': content,
           };
         }
    
         // Convert a Map into a DiaryEntry
         factory DiaryEntry.fromMap(Map<String, dynamic> map) {
           return DiaryEntry(
             title: map['title'],
             content: map['content'],
           );
         }
       }

    Step 3: Create the GetX Controller

    1. Create a controllers directory and a file diary_controller.dart:
       // lib/controllers/diary_controller.dart
       import 'package:get/get.dart';
       import '../models/diary_entry.dart';
    
       class DiaryController extends GetxController {
         var diaryEntries = <DiaryEntry>[].obs;
    
         void addEntry(DiaryEntry entry) {
           diaryEntries.add(entry);
         }
    
         void removeEntry(int index) {
           diaryEntries.removeAt(index);
         }
       }

    Step 4: Build the UI

    1. Create a screens directory and add a file home_screen.dart:
       // lib/screens/home_screen.dart
       import 'package:flutter/material.dart';
       import 'package:get/get.dart';
       import '../controllers/diary_controller.dart';
       import '../models/diary_entry.dart';
    
       class HomeScreen extends StatelessWidget {
         final DiaryController diaryController = Get.put(DiaryController());
    
         @override
         Widget build(BuildContext context) {
           return Scaffold(
             appBar: AppBar(
               title: Text('Diary App'),
               actions: [
                 IconButton(
                   icon: Icon(Icons.add),
                   onPressed: () {
                     Get.to(() => AddEntryScreen());
                   },
                 ),
               ],
             ),
             body: Obx(() {
               return ListView.builder(
                 itemCount: diaryController.diaryEntries.length,
                 itemBuilder: (context, index) {
                   final entry = diaryController.diaryEntries[index];
                   return ListTile(
                     title: Text(entry.title),
                     subtitle: Text(entry.content),
                     trailing: IconButton(
                       icon: Icon(Icons.delete),
                       onPressed: () {
                         diaryController.removeEntry(index);
                       },
                     ),
                   );
                 },
               );
             }),
           );
         }
       }
    1. Create an add_entry_screen.dart for adding new diary entries:
       // lib/screens/add_entry_screen.dart
       import 'package:flutter/material.dart';
       import 'package:get/get.dart';
       import '../controllers/diary_controller.dart';
       import '../models/diary_entry.dart';
    
       class AddEntryScreen extends StatelessWidget {
         final DiaryController diaryController = Get.find();
         final TextEditingController titleController = TextEditingController();
         final TextEditingController contentController = TextEditingController();
    
         @override
         Widget build(BuildContext context) {
           return Scaffold(
             appBar: AppBar(
               title: Text('Add Diary Entry'),
             ),
             body: Padding(
               padding: const EdgeInsets.all(16.0),
               child: Column(
                 children: [
                   TextField(
                     controller: titleController,
                     decoration: InputDecoration(labelText: 'Title'),
                   ),
                   TextField(
                     controller: contentController,
                     decoration: InputDecoration(labelText: 'Content'),
                     maxLines: 5,
                   ),
                   SizedBox(height: 20),
                   ElevatedButton(
                     onPressed: () {
                       final entry = DiaryEntry(
                         title: titleController.text,
                         content: contentController.text,
                       );
                       diaryController.addEntry(entry);
                       Get.back();
                     },
                     child: Text('Add Entry'),
                   ),
                 ],
               ),
             ),
           );
         }
       }

    Step 5: Set Up Main Entry Point

    1. Modify main.dart to set up GetX routing:
       // lib/main.dart
       import 'package:flutter/material.dart';
       import 'package:get/get.dart';
       import 'screens/home_screen.dart';
    
       void main() {
         runApp(MyApp());
       }
    
       class MyApp extends StatelessWidget {
         @override
         Widget build(BuildContext context) {
           return GetMaterialApp(
             title: 'Diary App',
             theme: ThemeData(
               primarySwatch: Colors.blue,
             ),
             home: HomeScreen(),
           );
         }
       }

    Step 6: Testing

    Run your app using:

    flutter run

    Output

    You should be able to add, view, and delete diary entries. Diary App using Flutter with GetX

    Feel free to expand this app with more features like data persistence, notifications, or enhanced UI. If you need help with any specific feature or run into any issues, just let me know!

    Related Articles

    • 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 QR Scanner 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
    • Creating an Instruction UI Screen in Flutter Application
    • Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile

    Share. Facebook Twitter LinkedIn WhatsApp Telegram Pinterest Reddit Email
    Previous ArticleHow to Create Music Player UI screen with fully functional in flutter
    Next Article Animated Backgrounds in Flutter: A Complete Guide

    Related Posts

    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

    Create custom social login button Google, Facebook and Apple ui in Flutter

    FLUTTER APP 4 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.