Add onImagePaste in example

pull/951/head
X Code 3 years ago
parent 5228f389ba
commit 3f5db3d151
  1. 10
      example/lib/pages/home_page.dart

@ -110,6 +110,7 @@ class _HomePageState extends State<HomePage> {
placeholder: 'Add content',
expands: false,
padding: EdgeInsets.zero,
onImagePaste: _onImagePaste,
customStyles: DefaultStyles(
h1: DefaultTextBlockStyle(
const TextStyle(
@ -351,6 +352,15 @@ class _HomePageState extends State<HomePage> {
);
}
Future<String> _onImagePaste(Uint8List imageBytes) async {
// Copies the picked file from temporary cache to applications directory
final appDocDir = await getApplicationDocumentsDirectory();
final file = await File(
'${appDocDir.path}/${basename('${DateTime.now().millisecondsSinceEpoch}.png')}')
.writeAsBytes(imageBytes);
return file.path.toString();
}
Future<void> _addEditNote(BuildContext context, {Document? document}) async {
final isEditing = document != null;
final quillEditorController = QuillController(

Loading…
Cancel
Save