Skip to content
geeksforgeeks
  • 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
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Data Types
  • Functions
  • Oops
  • Collections
  • Sets
  • Dart Interview Questions
  • Fluter
  • Android
  • Kotlin
  • Kotlin Android
  • Android with Java
  • Android Studio
Open In App
Next Article:
Flutter - Color Picker Application
Next article icon

Flutter Quill - Rich Text Editor in Flutter Application

Last Updated : 24 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

This post will explain how to integrate a rich text editor into your Flutter application so that it may enable rich text editing. There are many more things we can do with Flutter Quill, but they can get a little involved. The example below is a pretty basic demonstration of what we mean. Let's first discuss what flutter quill is and why we need it before moving further.

Flutter Quill is a Rich Text Editor and a Quill Component for Flutter

  • Allows users to write long articles with highly customisable text. features like adding numbered lists bulleted list hyperlinks etc
  • We can also add images into the editor (we won't be discussing it here)
  • Quill uses a format known as Delta that may be saved in our database as JSON, meaning that all user-submitted custom data and other data will be preserved without any data loss in between.

Step By Step Implementation

Step 1: Create a New Project in Android Studio

To set up Flutter Development on Android Studio please refer to Android Studio Setup for Flutter Development, and then create a new project in Android Studio please refer to Creating a Simple Application in Flutter.

Step 2: Install flutter_quill

dependencies:
flutter_quill: ^7.4.6

We are using version 7.4.6 but i suggest using the latest version while you are implementing it.

Step 3: Import it in your file where required

Dart
import 'package:flutter_quill/flutter_quill.dart' as quill; 

Keep in mind to import it as quill to avoid seeing duplicate definition errors. For example, since Text is defined in both material.dart and flutter_quill.dart, we can prevent this conflict by using the "as" keyword.

Step 4: Create a quill controller

Dart
final quill.QuillController controller = quill.QuillController.basic(); 

It's easy to construct an empty controller, which means that there are no data in the document that goes with it.

Step 5: Add the quill editor and pass the previously defined controller

Dart
quill.QuillEditor(         // padding          padding: const EdgeInsets.all(8),         // Pass the controller here         controller: controller,         // if you want to control the scroll define           // a scroll controller and pass it here         scrollController: ScrollController(),         // set true if you want the editor to be            // scrollable when the keyboard appears or too much content         scrollable: true,         // pass a focus node if you want to            // control when the keyboard appears         focusNode: FocusNode(),         // if true the keyboard will appear            // when the widget is rendered         autoFocus: false,         // set true if you want           // to disable editing         readOnly: false,         // set true if you want the editor to           // expand and occupy all the available space         expands: false,         // if there is no content this           // text will be displayed         placeholder: 'Add your data here...',       ) 

Although there are many more helpful arguments, this quill editor is defined with all the necessary arguments.

Step 6: Add a tool bar enabling custom texts

Dart
quill.QuillToolbar.basic(controller: controller) 

This creates a basic tool bar with font, size, bold text features etc. Now all you have to do is group all the code

Complete Code

Dart
import 'package:flutter/material.dart'; import 'package:flutter_quill/flutter_quill.dart' as quill;  void main() {   runApp(const MyApp()); }  class MyApp extends StatelessWidget {   const MyApp({super.key});    @override   Widget build(BuildContext context) {     final quill.QuillController controller = quill.QuillController.basic();     return MaterialApp(       home: Scaffold(         appBar: AppBar(           title: const Text('Quill Editor'),         ),         // Quill Editor         body: Column(           children: [             quill.QuillToolbar.basic(controller: controller),             quill.QuillEditor(               // padding               padding: const EdgeInsets.all(8),               // Pass the controller here               controller: controller,               // if you want to control the scroll define a                // scroll controller and pass it here               scrollController: ScrollController(),               // set true if you want the editor to be scrollable               // when the keyboard appears or too much content               scrollable: true,               // pass a focus node if you want to control               // when the keyboard appears               focusNode: FocusNode(),               // if true the keyboard will appear                // when the widget is rendered               autoFocus: false,               // set true if you want to disable editing               readOnly: false,               // set true if you want the editor to expand and                // occupy all the available space               expands: false,               // if there is no content this               // text will be displayed               placeholder: 'Add your data here...',             ),           ],         ),       ),     );   } } 

Output:

This is how the output looks like:

WhatsApp-Image-2023-10-15-at-113906-PM
Home screen

How to save and access saved document?

Getting the data from the controller in delta format and then convert it to JSON:

Dart
import 'dart:convert';  final String data = jsonEncode(controller.document.toDelta().toJson()); 

Although the data is in string form here, it includes all of its original information because it was translated from Delta to JSON. It will now be saved as a string if you wish to store it in a database or local storage.

Converting string back into delta format and passing it to the controller:

Convert the JSON back to Delta and then to Document when you wish to start the editor with any saved data.

Dart
final quill.QuillController controller = quill.QuillController(       document: quill.Document.fromJson(           jsonDecode(           // JSON needs to be put here           )),       selection: const TextSelection.collapsed(offset: 0),     ); 

There will be an issue while running this code because I haven't included any JSON in the JSON decode function. The saved JSON only has to be passed to the jsonDecode function.


Next Article
Flutter - Color Picker Application
author
shravangk
Improve
Article Tags :
  • Dart
  • Flutter

Similar Reads

  • Photo Editing Application in Flutter
    With the introduction of the powerful image_editor_plus package, editing images directly within your Flutter app has become significantly more accessible. In this article, we'll dive deep into building a user-friendly image editor app. Users will have the ability to select an image from their camera
    7 min read
  • Recipe Finder Application in Flutter
    This app will display a list of recipes in a card format, each containing the recipe title, a rating, the cooking time, and a thumbnail image to give users a visual preview. The app is dynamic and flexible, allowing you to easily update the recipe list or modify the UI as needed. By the end of this
    5 min read
  • EBook reader Application in Flutter
    EBook reader Application brings the library to your fingertips. This application will be the travel partner of every book lover who loves to read books of their choice. The app is developed using Flutter and provider state management. It uses the Google Books API to fetch the data of books. The app
    8 min read
  • Flutter - Color Picker Application
    If the app involves a color picking system, we can do it effortlessly in Flutter using the flutter_colorpicker library. It is easy to customize which saves time and enhances the user experience. In this article, we will be creating color pickers using the flutter_colorpicker library. Follow along fo
    4 min read
  • Creating a Simple Application in Flutter
    Flutter is an open-source cross-platform mobile application development SDK created by Google. It is highly user-friendly and builds high-quality mobile applications. The intention behind this article is to guide readers through the process of building an application through Flutter by creating a si
    5 min read
  • Application Localization in Flutter
    In mobile applications, Localization is the process of adapting an application to support multiple languages and regional settings. This allows your app to be more accessible to users from different parts of the world. In Flutter, for implementing Localization flutter_localization is a package used
    4 min read
  • How to Change the Color of the Status Bar in Flutter Application?
    Flutter is an open-source UI toolkit developed and maintained by Google. It is used by big companies like Airbnb, Alibaba, and Google itself to serve billions of users around the globe. Status Bar is the topmost area of the screen which is home to the Battery Indicator, Network Status, Time, Notific
    1 min read
  • How to Build a ToDo Application in Flutter?
    Flutter offers a stable framework for constructing richly UI-driven cross-platform applications. In this article, we will learn to build a ToDo Flutter Application. What is the ToDo Application?The ToDo application helps users manage and organize their tasks and responsibilities more easily. Managin
    6 min read
  • Expense Tracker Application Flutter
    In this tutorial, we will create a Flutter app that allows users to track their daily expenses and income, visualize spending patterns through charts, and store transaction data locally using Hive. This application will showcase how to handle user input, visualize data, and ensure local data persist
    10 min read
  • How to Create a Desktop Window Application in Flutter?
    The Flutter team recently released Flutter version 2.10 with Desktop support. Desktop support allows you to compile Flutter source code to a native Windows, macOS, or Linux desktop app. Flutter’s desktop support also extends to plugins—you can install existing plugins that support the Windows, macOS
    3 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