flutter summernote
text editor in flutter for android and ios to help free write wysiwyg html code based on summernote 0.8.18 javascript wrapper.
setup
add flutter_summernote: ^latest
as deppendecy to pubspec.yaml
ios
add the following keys to your info.plist file, located in <project root>
/ios/runner/info.plist:
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>nscamerausagedescription</key>
<string>used to demonstrate image picker plugin</string>
<key>nsmicrophoneusagedescription</key>
<string>used to capture audio for image picker plugin</string>
<key>nsphotolibraryusagedescription</key>
<string>used to demonstrate image picker plugin</string>
<key>nsapptransportsecurity</key>
<dict>
<key>nsallowsarbitraryloads</key>
<true/>
</dict>
usage
- import flutter html editor
import 'package:flutter_summernote/flutter_summernote.dart';
- create global key from html editor state
globalkey<fluttersummernotestate> _keyeditor = globalkey();
- add html editor to widget
fluttersummernote(
hint: "your text here...",
key: _keyeditor
),
fluttersummernote(
hint: "your text here...",
key: _keyeditor,
customtoolbar: """
[
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']]
]"""
)
- get text from html editor
final _eteditor = await keyeditor.currentstate.gettext();
avalaible option parameters
parameter | type | default | description |
---|---|---|---|
key | globalkey<htmleditorstate> |
required | for get method & reset |
value | string | empty | iniate text content for text editor |
height | double | 380 | height of text editor |
decoration | boxdecoration | empty | decoration editor |
widthimage | string | 100% | width of image picker |
hint | string | empty | placeholder hint text |
customtoolbar | string | empty | add all available toolbar. don’t use insert (video & picture), please use hasattachment option. |
hasattachment | boolean | false | use this option if yout want to show or hide attachment button |
showbottomtoolbar | boolean | false | use this option if yout want to show or hide bottom toolbar |
Comments are closed.