Fixed keyboard closing and reopening when writing messages

This commit is contained in:
Elias Müller 2023-09-09 17:24:40 +02:00
parent 7b4c698a8e
commit 7a411a34c9
2 changed files with 11 additions and 10 deletions
lib/view/pages

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

@ -24,7 +24,6 @@ class ChatTextfield extends StatefulWidget {
class _ChatTextfieldState extends State<ChatTextfield> {
final TextEditingController _textBoxController = TextEditingController();
bool sending = false;
bool isLoading = false;
void _query() {
@ -128,7 +127,6 @@ class _ChatTextfieldState extends State<ChatTextfield> {
color: Colors.white,
),
controller: _textBoxController,
readOnly: sending,
maxLines: 7,
minLines: 1,
decoration: InputDecoration(
@ -143,20 +141,24 @@ class _ChatTextfieldState extends State<ChatTextfield> {
mini: true,
onPressed: (){
if(_textBoxController.text.isEmpty) return;
if(isLoading) return;
setState(() {
sending = true;
isLoading = true;
});
SendMessage(widget.sendToToken, SendMessageParams(_textBoxController.text)).run().then((value) => {
_query(),
_textBoxController.text = "",
SendMessage(widget.sendToToken, SendMessageParams(_textBoxController.text)).run().then((value) {
_query();
setState(() {
sending = false;
}),
isLoading = false;
});
_textBoxController.text = "";
});
},
backgroundColor: Theme.of(context).primaryColor,
elevation: 5,
child: const Icon(Icons.send, color: Colors.white, size: 18),
child: isLoading
? Container(padding: const EdgeInsets.all(10), child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
: const Icon(Icons.send, color: Colors.white, size: 18),
),
],
),