rich_code_editor 0.1.0 rich_code_editor: ^0.1.0 copied to clipboard
Now create your own rich code editor in Flutter. Similar to a TextField, you can make use of the RichTextField widget to create code editor with syntax highlight support for any programming lanugages.
rich_code_editor #
A simple package that supports creating code editors in Flutter.
Getting Started #
Create your own implementation of RichTextEditingValueParserBase
for any programming language of your choice and pass it to the RichTextField
.
Check out example project for getting started with this project.
Explanation of most of the classes/widgets created #
- RichTextField
- similar to TextField widget
- top level widget that wraps everything inside
- RichTextFieldState
- extends State
- RenderRichEditable
- extends RenderBox
- renderer for an editable text field
- It does not directly provide affordances for editing the text,
- but it does handle text selection and manipulation of the text cursor.
- RichTextEditingValueParser
- responsible for parsing text and style
- RichTextEditingValue
- extends AbstractTextEditingValue
- similar to TextEditingValue
- uses TextSpan instead of String
- AbstractTextEditingValue
- abstract class
- TextInputClient
- abstract class
- T type where
- an interface to receive information from TextInput
- same as Flutter's TextInputClient
- plus getValue to get value
- TextInputConnection
- a interface for interacting with a text input control.
- same as Flutter's TextInputConnection
- but with setEditingState taking AbstractTextEditingValue as argument
- requires TextInputClient _client that the connection should be established with (RichEditableTextState)
- _TextInputClientHandler
- same as Flutter's _TextInputClientHandler
- TextInput
- an interface to the system's text input control.
- same as Flutter's TextInput minus debug info/assertion
- RichTextEditingController
- extends ValueNotifier of type
- similar to TextEditingController but for
- RichEditableText
- similar to EditableText
- RichEditableTextState
- extends State
- implements TextInputClient
- parent for
_RichEditable
- _RichEditable
- extends LeafRenderObjectWidget
- The createRenderObject & updateRenderObject methods update output TextSpans by calling
RichTextEditingValueParser.updateSpansWithStyle
- Extensions
- utilities for working with TextSpan
Credits #
A big thanks to Razvan Lung for starting the Rich text editor project "https://github.com/long1eu/rich_editor". Most of the codes have been used from his repo and adjusted as needed.