[英]How to resolve background issue in flutter
在我的 android flutter 应用程序中,在输入电话号码的文本框中输入后,电话文本框没有移动到顶部。 它被数字隐藏了。 那么,如何解决这个问题? 背景图片 bg.png 大小为 789X1665。 那么,需要调整 bg 图片的大小还是需要添加一些代码更改? 请帮助任何人解决此问题。
return Scaffold(
resizeToAvoidBottomInset : false,
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image : DecorationImage(
image: AssetImage('images/bg.png'),
fit: BoxFit.contain
)
),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(height: 500,),
Container(
margin:EdgeInsets.only(top: 10),
child: const Center(
child: Text(
"Phone (OTP) Authentication",
style:TextStyle(fontWeight: FontWeight.bold,fontSize: 20) ,
),
),
),
SizedBox(height: 10,),
SizedBox(
width: 400,
height: 50,
child: CountryCodePicker(
onChanged: (country){
setState(() {
dialCodeDigits = country.dialCode!;
});
},
initialSelection: "IN",
showCountryOnly: false,
showOnlyCountryWhenClosed: false,
favorite: ["+1", "US", "+91", "IND"],
hideSearch: true,
showDropDownButton: false,
enabled: false,
),
),
Container(
margin: EdgeInsets.only(top: 10,right: 10,left: 10),
child: TextField(
decoration: InputDecoration(
hintText: "Phone Number",
prefix: Padding(
padding: EdgeInsets.all(4),
child: Text(dialCodeDigits!),
)
),
maxLength: 12,
keyboardType: TextInputType.number,
controller: _controller,
),
),
Container(
margin: EdgeInsets.all(15),
width: double.infinity,
child: ElevatedButton(
onPressed: (){
Navigator.of(context).push(MaterialPageRoute(builder: (c) => OTPControllerScreen(
phone: _controller.text,
codeDigits: dialCodeDigits!,
)));
},
child: Text('Next',style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),),
),
),
],
),
)
)
);
使用resizeToAvoidBottomInset=true;
指定当键盘出现时主体是否应调整大小。 您还可以使用SingleChildScrollView()
包装父Container()
)
您应该删除resizeToAvoidBottomInset: false,
,这应该可以解决您的问题,而且您也不应该这样做SizedBox(height: 500,),
或SizedBox( width: 400, height: 50,
使用padding代替!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.