Tested on Gboard on Android.
See: https://developer.android.com/develop/ui/views/touch-and-input/image-keyboard
See: https://github.com/flutter/flutter/pull/110052
See: https://api.flutter.dev/flutter/material/TextField/contentInsertionConfiguration.html
---
lib/widget/composer.dart | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/widget/composer.dart b/lib/widget/composer.dart
index 4bab95e..0bb2455 100644
--- a/lib/widget/composer.dart
+++ b/lib/widget/composer.dart
@@ -513,6 +513,7 @@ class ComposerState extends State<Composer> {
}
Widget _buildTextField(BuildContext context, TextEditingController controller, FocusNode focusNode, VoidCallback onFieldSubmitted) {
+ var client = context.read<Client>();
var prefs = context.read<Prefs>();
var sendTyping = prefs.typingIndicator;
@@ -548,6 +549,16 @@ class ComposerState extends State<Composer> {
minLines: 1,
maxLines: 5,
keyboardType: TextInputType.text, // disallows newlines
+ contentInsertionConfiguration: (client.isupport.filehost != null) ? ContentInsertionConfiguration(
+ allowedMimeTypes: const <String>['image/jpeg', 'image/png', 'image/gif'],
+ onContentInserted: (KeyboardInsertedContent data) async {
+ if (data.hasData) {
+ _runAddMenuTask(() async {
+ await _uploadFile(XFile.fromData(data.data!, mimeType: data.mimeType, path: data.uri));
+ });
+ }
+ },
+ ) : null,
);
}
base-commit: 2d16a7005d5ace641d69bf795c97c05244fa67cb
--
2.38.0