如何防止Flutter小部件在键盘出现时调整大小?

问题描述 投票:0回答:1

出现键盘时,Flutter窗口小部件将调整大小。如何在不使用

的情况下防止这种情况
resizeToAvoidBottomInset : false,

如果我将其设置为假,则因为键盘在其上方,所以我看不到TextFormField怎么办?这是我的代码

    return Scaffold(
//      resizeToAvoidBottomInset : false,
      body: Center(
        child: Stack(
          children: <Widget>[
            SizedBox(
              height: MediaQuery.of(context).size.height,
              width: MediaQuery.of(context).size.width,
              child: Image.asset('images/back_ui4.png',fit: BoxFit.fill,),
            ),
            SingleChildScrollView(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  SizedBox(height: 0.7*MediaQuery.of(context).size.height,),
                  TextFormField()
                ],
              ),
            ),
          ],
        ),
      ),
    );

flutter keyboard scrollview textfield scaffold
1个回答
0
投票
return Scaffold(
      body: SingleChildScrollView(
        child : Center(
        child: Stack(
          children: <Widget>[
            SizedBox(
              height: MediaQuery.of(context).size.height,
              width: MediaQuery.of(context).size.width,
              child: Image.asset('images/back_ui4.png',fit: BoxFit.fill,),
            ),
            Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  SizedBox(height: 0.7*MediaQuery.of(context).size.height,),
                  TextFormField()
                ],
              ),
            ),
          ],
        ),
      ),
    );
© www.soinside.com 2019 - 2024. All rights reserved.