如何使用按鈕或 GestureDetector 激活 textField 并顯示鍵盤,我已經創建了代碼,但是當我第二次單擊按鈕或gestureDetector 時,鍵盤沒有顯示,并且 textFiled 上的游標仍然存在
我正在使用 getX
手勢檢測器
GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(controller.textFieldFocus);
},
child: Container(
// height: 25.0,
margin: EdgeInsets.symmetric(horizontal: 20.0),
padding:
EdgeInsets.only(left: 5.0, right: 240.0, top: 5.0, bottom: 5.0),
decoration: Ui.getBoxDecoration(
color: Get.theme.primaryColor,
border: Border.all(
color: Color.fromRGBO(149, 151, 161, 1),
width: 1.0,
),
radius: 14.0,
),
child: Text(
"reply the comment...",
style: TextStyle(
color: Color.fromRGBO(149, 151, 161, 1),
fontFamily: 'Roboto',
fontSize: 12,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1,
),
),
),
);
文本域
TextField(
controller: controller.textEditingController,
onSubmitted: (value) {
//
},
focusNode: controller.textFieldFocus, //i using getX
style: TextStyle(
color: Color.fromRGBO(149, 151, 161, 1),
fontFamily: 'Roboto',
fontSize: 12,
letterSpacing: 0,
fontWeight: FontWeight.normal,
height: 1,
),
autofocus: false,
cursorColor: Get.theme.focusColor,
decoration: Ui.getInputDecoration(
hintText: "add a comment...".tr,
),
keyboardType: TextInputType.multiline,
maxLines: null,
expands: true,
),
uj5u.com熱心網友回復:
這篇Flutter 食譜文章描述了如何在點擊按鈕時將焦點傳遞給文本欄位,并且應該可以解決您的問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/387085.html
上一篇:在顫振中簽署okexapi
