When the keyboard opens, it might be causing the bottom sheet to close, which will then result in disposing any widgets inside it.
globals.addinfolistitem[widget.shotlistindex]
[widget.projectindex]
.add('Add');
shottypefocusnode.add(FocusNode());
print("FocusNode");
This is the one of the optiosn inside the BottomBar,the function is when the item is triggered then craete a new listitem in the container and bottombar will to close and the soft keyboard and cursor will focus on the TextFields. But now the soft keyboard is hidden.
BottomBar(Widget popupmenu) {
showModalBottomSheet(
constraints: BoxConstraints(
maxHeight: globals.slidingpanelmaxheight.isNaN
? 500
: globals.slidingpanelmaxheight,
maxWidth: MediaQuery
.of(context)
.size
.width - 10,
),
backgroundColor: Colors.transparent,
context: context,
builder: (context) {
return popupmenu;
}).then((value) {
print("popupmenu bottom sheet closed");
// Set focus on TextField
if (!myFocusNode.hasFocus) {
FocusScope.of(context).requestFocus(myFocusNode);
}
});
}
I try to request focus again when the bottom sheet closed but doesnt work. enter image description here
Once the BottomBar items is triggered then add the selected item to the container and soft keyboard focus on the Textfields
First of all, I think I do not fully understand the problem, but as far as I understand, I hope that if you make the following structure according to one of the appropriate state management methods, it will work.