dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
4 years ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_quill/widgets/controller.dart';
|
||
|
import 'package:flutter_quill/widgets/editor.dart';
|
||
|
|
||
4 years ago
|
import '../widgets/demo_scaffold.dart';
|
||
|
|
||
4 years ago
|
class ReadOnlyPage extends StatefulWidget {
|
||
|
@override
|
||
|
_ReadOnlyPageState createState() => _ReadOnlyPageState();
|
||
|
}
|
||
|
|
||
|
class _ReadOnlyPageState extends State<ReadOnlyPage> {
|
||
|
final FocusNode _focusNode = FocusNode();
|
||
|
|
||
|
bool _edit = false;
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return DemoScaffold(
|
||
|
documentFilename: 'sample_data.json',
|
||
|
builder: _buildContent,
|
||
|
showToolbar: _edit == true,
|
||
|
floatingActionButton: FloatingActionButton.extended(
|
||
|
label: Text(_edit == true ? 'Done' : 'Edit'),
|
||
|
onPressed: _toggleEdit,
|
||
|
icon: Icon(_edit == true ? Icons.check : Icons.edit)),
|
||
|
);
|
||
|
}
|
||
|
|
||
4 years ago
|
Widget _buildContent(BuildContext context, QuillController? controller) {
|
||
4 years ago
|
return Padding(
|
||
|
padding: const EdgeInsets.all(8.0),
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
border: Border.all(color: Colors.grey.shade200),
|
||
|
),
|
||
|
child: QuillEditor(
|
||
4 years ago
|
controller: controller!,
|
||
4 years ago
|
scrollController: ScrollController(),
|
||
|
scrollable: true,
|
||
|
focusNode: _focusNode,
|
||
|
autoFocus: true,
|
||
|
readOnly: !_edit,
|
||
|
enableInteractiveSelection: true,
|
||
|
expands: false,
|
||
|
padding: EdgeInsets.zero,
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
void _toggleEdit() {
|
||
|
setState(() {
|
||
|
_edit = !_edit;
|
||
|
});
|
||
|
}
|
||
|
}
|