mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: add empty document entry in example
This commit is contained in:
parent
58d656d9f4
commit
eb7c65aa8b
@ -1,3 +1,4 @@
|
||||
import 'dart:collection';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:example/expandable_floating_action_button.dart';
|
||||
@ -80,12 +81,21 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
icon: const Icon(Icons.note_add),
|
||||
),
|
||||
ActionButton(
|
||||
icon: const Icon(Icons.document_scanner),
|
||||
onPressed: () {
|
||||
if (page == 1) return;
|
||||
setState(() {
|
||||
page = 1;
|
||||
});
|
||||
},
|
||||
),
|
||||
ActionButton(
|
||||
onPressed: () {
|
||||
if (page == 2) return;
|
||||
setState(() {
|
||||
page = 2;
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.text_fields),
|
||||
),
|
||||
],
|
||||
@ -97,11 +107,41 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
if (page == 0) {
|
||||
return _buildFlowyEditor();
|
||||
} else if (page == 1) {
|
||||
return _buildFlowyEditorWithEmptyDocument();
|
||||
} else if (page == 2) {
|
||||
return _buildTextField();
|
||||
}
|
||||
return Container();
|
||||
}
|
||||
|
||||
Widget _buildFlowyEditorWithEmptyDocument() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(left: 20, right: 20),
|
||||
child: FlowyEditor(
|
||||
key: editorKey,
|
||||
editorState: EditorState(
|
||||
document: StateTree(
|
||||
root: Node(
|
||||
type: 'editor',
|
||||
children: LinkedList()
|
||||
..add(
|
||||
TextNode.empty()
|
||||
..delta = Delta(
|
||||
[TextInsert('')],
|
||||
),
|
||||
),
|
||||
attributes: {},
|
||||
),
|
||||
),
|
||||
),
|
||||
keyEventHandlers: const [],
|
||||
customBuilders: {
|
||||
'image': ImageNodeBuilder(),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFlowyEditor() {
|
||||
return FutureBuilder<String>(
|
||||
future: rootBundle.loadString('assets/example.json'),
|
||||
|
Loading…
Reference in New Issue
Block a user