@@ -362,6 +362,31 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
362362 }
363363 }
364364
365+ void _handleContentInserted (KeyboardInsertedContent content) async {
366+ final url = Uri .tryParse (content.uri);
367+ // TODO: is this correct?
368+ String filename = (url == null || url.pathSegments.isEmpty)
369+ ? 'file'
370+ : url.pathSegments.last;
371+
372+ if (! content.hasData) {
373+ // TODO: investigate how data can be null and handle it
374+ return ;
375+ }
376+
377+ final file = _File (
378+ content: Stream .fromIterable ([content.data! ]),
379+ length: content.data! .length,
380+ filename: filename,
381+ mimeType: content.mimeType);
382+
383+ await _uploadFiles (
384+ context: context,
385+ contentController: widget.controller.content,
386+ contentFocusNode: widget.controller.contentFocusNode,
387+ files: [file]);
388+ }
389+
365390 static double maxHeight (BuildContext context) {
366391 final clampingTextScaler = MediaQuery .textScalerOf (context)
367392 .clamp (maxScaleFactor: 1.5 );
@@ -405,6 +430,8 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
405430 child: TextField (
406431 controller: widget.controller.content,
407432 focusNode: widget.controller.contentFocusNode,
433+ contentInsertionConfiguration: ContentInsertionConfiguration (
434+ onContentInserted: _handleContentInserted),
408435 // Let the content show through the `contentPadding` so that
409436 // our [InsetShadowBox] can fade it smoothly there.
410437 clipBehavior: Clip .none,
0 commit comments