rich_editor
Version 0.0.4
Wysiwyg flutter編輯器具有豐富的支持格式選項。
基於https://github.com/dankito/richtexteditor,但用於撲朔迷離。

// Insert widget into tree
RichEditor (
key : keyEditor,
value : 'initial html here' ,
editorOptions : RichEditorOptions (
placeholder : 'Start typing' ,
// backgroundColor: Colors.blueGrey, // Editor's bg color
// baseTextColor: Colors.white,
// editor padding
padding : EdgeInsets . symmetric (horizontal : 5.0 ),
// font name
baseFontFamily : 'sans-serif' ,
// Position of the editing bar (BarPosition.TOP or BarPosition.BOTTOM)
barPosition : BarPosition . TOP ,
),
// You can return a Link (maybe you need to upload the image to your
// storage before displaying in the editor or you can also use base64
getImageUrl : (image) {
String link = 'https://avatars.githubusercontent.com/u/24323581?v=4' ;
String base64 = base64Encode (image. readAsBytesSync ());
String base64String = 'data:image/png;base64, $ base64 ' ;
return base64String;
},
)從編輯器獲取當前的HTML
String ? html = await keyEditor.currentState ? . getHtml ();
print (html);設定重點並取消關注
await keyEditor.currentState ? . focus ();
await keyEditor.currentState ? . unFocus ();清除編輯器內容
await keyEditor.currentState ? . clear ();如果您有興趣創建自己的工具欄檢查示例中的custom_toolbar_demo.dart
Copyright 2021 JideGuru
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.