i want to pop showModalBottomSheet when i clicked the button of back in android mobile. this is my showModalBottomSheet example :
showModalBottomSheet(
context: contextt,
useRootNavigator: true,
isScrollControlled: true,
isDismissible: true,
enableDrag: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(mySize.curve_large),
),),
clipBehavior: Clip.antiAliasWithSaveLayer,
builder: (contextt) {
FocusScope.of(contextt).requestFocus(focusNode);
return SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: TextField(
controller: commentTextController,
cursorColor: theme.orange,
textAlignVertical: TextAlignVertical.center,
textAlign: TextAlign.center,
autofocus: true,
focusNode: focusNode,
maxLines: 2,
minLines: 1,
autocorrect: true,
enableInteractiveSelection: true,)); });},
if i just use show modal bottomsheet back button is work but in use text input in it . so when i click back , the sheet not pop.
I use WillPopScope
before my example widget "TextInput", but its not work :
WillPopScope(
onWillPop: () async {
FocusScope.of(contextt).requestFocus(FocusNode());
Navigator.of(contextt).pop();
return false;
},
can anyone help me how can I do that?
and by the way, when I clicked the back button twice in a row, showModalBottomSheet popped. I want to do that with one click!.