Flutter Quill - Rich Text Editor in Flutter Application
Last Updated : 24 Apr, 2025
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:
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.
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