文本输入markdown,上传也是获取到markdown文档,使用了开源Zefyr 一款Flutter实现的富文本编辑;开源Zefyr无非兼容新fluter版本
github:https://github.com/memspace/zefyr
Zefyr:0.5.0
输入框
Widget _descriptionEditor() {
final theme = new ZefyrThemeData(
toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
color: Colors.grey.shade800,
toggleColor: Colors.grey.shade900,
iconColor: Colors.white,
disabledIconColor: Colors.grey.shade500,
),
);
return ZefyrTheme(
data: theme,
child: ZefyrField(
height: 400.0,
decoration: InputDecoration(labelText: 'Description'),
controller: _zefyrController,
focusNode: _focusNode,
autofocus: true,
physics: ClampingScrollPhysics(),
),
);
}
监听数据
测试数据如下图
@override
void initState() {
_zefyrController.document.changes.listen((change) {
setState(() {
//获取数据的方式有一些
_delta = _zefyrController.document.toDelta();
json = _zefyrController.document.toJson();
string = _zefyrController.document.toString();
plainText = _zefyrController.document.toPlainText();
});
});
super.initState();
}
输入效果图如下:
日志显示结果:
_delta = _zefyrController.document.toDelta();
json = _zefyrController.document.toJson();
string = _zefyrController.document.toString();
plainText = _zefyrController