@@ -362,6 +362,31 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
362
362
}
363
363
}
364
364
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
+
365
390
static double maxHeight (BuildContext context) {
366
391
final clampingTextScaler = MediaQuery .textScalerOf (context)
367
392
.clamp (maxScaleFactor: 1.5 );
@@ -405,6 +430,8 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
405
430
child: TextField (
406
431
controller: widget.controller.content,
407
432
focusNode: widget.controller.contentFocusNode,
433
+ contentInsertionConfiguration: ContentInsertionConfiguration (
434
+ onContentInserted: _handleContentInserted),
408
435
// Let the content show through the `contentPadding` so that
409
436
// our [InsetShadowBox] can fade it smoothly there.
410
437
clipBehavior: Clip .none,
0 commit comments