解决Flutter中软键盘遮挡底部弹窗问题

      

showModalBottomSheet(
      context: context,
      isScrollControlled: true,//显示的底部弹出框(Bottom Sheet)是否能够根据内容大小进行滚动。
      builder: (BuildContext context) {
        return StatefulBuilder(
            builder: (context, setState) {
          final keyboardHeight = MediaQuery.of(context).viewInsets.bottom;//检测软键盘是否弹出
          return Padding(
              padding: EdgeInsets.only(bottom: keyboardHeight),//设置底部内边距为软件盘高度
              child:
              ClipRRect(
                  borderRadius:
                      const BorderRadius.vertical(
                    top: Radius.circular(20),
                  ),
                  child: Container(
                      color: Colors.white,
                      height: 300.w,
                      width: double.infinity,
                      padding: const EdgeInsets.only(
                          top: 34.0, bottom: 20.0),
                      child: Column(
                        mainAxisAlignment:
                            MainAxisAlignment
                                .spaceBetween,
                        children: [
                          Text(
                            '修改密码',
                            style: TextStyle(
                              color:
                                  hexColor('#333333'),
                              fontSize: 20,
                            ),
                          ),
                          const SizedBox(height: 15.0),
                          // 弹窗中间部分处理
                          Expanded(
                            child: Center(
                              child: _option(),
                            ),
                          ),
                          const SizedBox(height: 15.0),
                          SizedBox(
                            width: 180.w,
                            child: OptBtn(
                                height: 52.w,
                                borderRadius: 26.0,
                                color:
                                    hexColor('#03B86F'),
                                borderColor:
                                    hexColor('#03B86F'),
                                textColor:
                                    hexColor('#FFFFFF'),
                                text: '确定',
                                onTap: () {
                                  Navigator.pop(
                                      context);
                                }),
                          )
                        ],
                      )));
          );
        });
      });

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值