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.
82 lines
2.3 KiB
82 lines
2.3 KiB
2 years ago
|
// ignore_for_file: avoid_redundant_argument_values
|
||
|
|
||
4 years ago
|
import 'package:flutter/foundation.dart';
|
||
4 years ago
|
import 'package:flutter/material.dart';
|
||
3 years ago
|
import 'package:flutter_quill/extensions.dart';
|
||
2 years ago
|
import 'package:flutter_quill/flutter_quill.dart';
|
||
3 years ago
|
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
|
||
4 years ago
|
|
||
4 years ago
|
import '../widgets/demo_scaffold.dart';
|
||
|
|
||
4 years ago
|
class ReadOnlyPage extends StatefulWidget {
|
||
1 year ago
|
const ReadOnlyPage({super.key});
|
||
|
|
||
4 years ago
|
@override
|
||
|
_ReadOnlyPageState createState() => _ReadOnlyPageState();
|
||
|
}
|
||
|
|
||
|
class _ReadOnlyPageState extends State<ReadOnlyPage> {
|
||
|
final FocusNode _focusNode = FocusNode();
|
||
|
|
||
|
bool _edit = false;
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return DemoScaffold(
|
||
1 year ago
|
documentFilename: isDesktop(supportWeb: false)
|
||
3 years ago
|
? 'assets/sample_data_nomedia.json'
|
||
|
: 'sample_data_nomedia.json',
|
||
4 years ago
|
builder: _buildContent,
|
||
|
showToolbar: _edit == true,
|
||
|
floatingActionButton: FloatingActionButton.extended(
|
||
2 years ago
|
label: Text(_edit == true ? 'Done' : 'Edit'),
|
||
|
onPressed: _toggleEdit,
|
||
|
icon: Icon(_edit == true ? Icons.check : Icons.edit),
|
||
|
),
|
||
4 years ago
|
);
|
||
|
}
|
||
|
|
||
4 years ago
|
Widget _buildContent(BuildContext context, QuillController? controller) {
|
||
4 years ago
|
var quillEditor = QuillEditor(
|
||
2 years ago
|
configurations: QuillEditorConfigurations(
|
||
|
expands: false,
|
||
|
padding: EdgeInsets.zero,
|
||
1 year ago
|
embedBuilders: kIsWeb
|
||
1 year ago
|
? FlutterQuillEmbeds.editorWebBuilders()
|
||
1 year ago
|
: FlutterQuillEmbeds.editorBuilders(),
|
||
2 years ago
|
scrollable: true,
|
||
|
autoFocus: true,
|
||
|
),
|
||
4 years ago
|
scrollController: ScrollController(),
|
||
|
focusNode: _focusNode,
|
||
2 years ago
|
// readOnly: !_edit,
|
||
4 years ago
|
);
|
||
|
if (kIsWeb) {
|
||
|
quillEditor = QuillEditor(
|
||
2 years ago
|
configurations: QuillEditorConfigurations(
|
||
|
autoFocus: true,
|
||
|
expands: false,
|
||
|
padding: EdgeInsets.zero,
|
||
1 year ago
|
embedBuilders: FlutterQuillEmbeds.editorWebBuilders(),
|
||
2 years ago
|
scrollable: true,
|
||
|
),
|
||
2 years ago
|
scrollController: ScrollController(),
|
||
|
focusNode: _focusNode,
|
||
|
);
|
||
4 years ago
|
}
|
||
1 year ago
|
return Container(
|
||
|
decoration: BoxDecoration(
|
||
|
border: Border.all(color: Colors.grey.shade200),
|
||
4 years ago
|
),
|
||
1 year ago
|
padding: const EdgeInsets.all(8),
|
||
|
child: quillEditor,
|
||
4 years ago
|
);
|
||
|
}
|
||
|
|
||
|
void _toggleEdit() {
|
||
|
setState(() {
|
||
|
_edit = !_edit;
|
||
|
});
|
||
|
}
|
||
|
}
|