flutter 使用keyboard_actions 关闭ios键盘

项目中登录 输入账号密码 弹出的键盘 关闭不了,从而 引来一些问题, 

1,第一次关闭 项目是在 最外层包裹一层,点击的时候进行关闭,

return Scaffold(
      resizeToAvoidBottomPadding: true, //输入框抵住键盘
      body: Builder(
       builder: (context) {
         FormKeyboardActions.setKeyboardActions(context, _buildConfig(context));
        return  ModalProgressHUD(
             inAsyncCall:_saving,
             color: Colors.black,
             progressIndicator: new CircularProgressIndicator(),
             child: InkWell(
               onTap:  (){
                 FocusScope.of(context).requestFocus(FocusNode());
               },
               child: defaultTargetPlatform == TargetPlatform.iOS ? FormKeyboardActions(
                 child: buildBody(),
               ) : SingleChildScrollView(
                 child: buildBody(),
               ) ,
             )
         );
       },
    ));

2.更坑爹的是用户不知道点击空白的时候关闭键盘,其实是一个用户的反馈,产品跟我说是一堆用户反馈。我去

进一步的需求是键盘的上方 需要加一个条进行关闭

 找了个插件 keyboard_actions 集成到项目中

遇到的问题是集成的过程中报了个错。

调用

FormKeyboardActions.setKeyboardActions(context, _buildConfig(context));
错误:Context does not contain a FormKeyboardActions ancestor: see Scaffold.of for reference.  

解决的办法是 路由进入的时候包一层

Navigator.of(context).push(
      MaterialPageRoute(
          builder: (_) => FormKeyboardActions(
                  child: SizedBox(
                 screenWidth(),
                height: screenHeight(),
                child: KeyboardTest(),
              ))),
    );
只有这一个问题比较坑,其他引入插件的过程中倒没遇到什么问题,就不一一记录了。
原文地址:https://www.cnblogs.com/wupeng88/p/11772029.html