v0.2.15
markdown_editor_plus
一个 TextField 小部件,可让您轻松地将 TextField 中的内容转换为 Markdown,并支持自定义工具栏。
73喜欢 3300近 30 天下载140Pub 分数
AndroidiOSWebmacOSWindowsLinux
适用于 Flutter 的 Markdown 编辑器及预览功能
{"sdk":"flutter"}^5.0.1^7.2.2^0.7.2+1^10.7.0{"sdk":"flutter"}^4.0.0以下为英文项目原文快照,最新内容请访问 GitHub。
This is a fork of simple_markdown_editor by zahnia88 with contributions from fossfreaks
Simple markdown editor library For flutter. For demo video, you can see it at this url Demo
Add dependencies to your pubspec.yaml
dependencies:
markdown_editor_plus: ^latest
Run flutter pub get to install.
Import library
import 'package:markdown_editor_plus/markdown_editor_plus.dart';
Initialize controller and focus node. These controllers and focus nodes are optional because if you don't create them, the editor will create them themselves
TextEditingController _controller = TextEditingController();
Show widget for editor
// editable text with toolbar by default
MarkdownAutoPreview(
controller: _controller,
emojiConvert: true,
)
// editable text without toolbar
MarkdownField(
controller: _controller,
emojiConvert: true,
enableToolBar: false,
)
if you want to parse text into markdown you can use the following widget:
String data = '''
**bold**
*italic*
#hashtag
@mention
'''
MarkdownParse(
data: data,
onTapHastag: (String name, String match) {
// name => hashtag
// match => #hashtag
},
onTapMention: (String name, String match) {
// name => mention
// match => #mention
},
)
In order to set the colors
MarkdownAutoPreview(
controller: _controller,
enableToolBar: true,
emojiConvert: true,
autoCloseAfterSelectEmoji: false,
// toolbar's background color, text color will be based on theme
toolbarBackground: Colors.blue,
// toolbar's expandable widget colors like headings, ordering
expandableBackground: Colors.blue[200],
)