[英]Android Flutter : I need to set the 'SingleChildScrollView' in the body?
This is my code,I need to set the SingleChildScrollView in the body.I want to scroll the entire screen.这是我的代码,我需要在正文中设置SingleChildScrollView 。我想滚动整个屏幕。
@override
Widget build(BuildContext context) {
return Scaffold(
body: Form(
key: _formKey,
child: Container(
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/login.jpg"),
fit: BoxFit.contain,
alignment: Alignment.topCenter)),
child: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
SizedBox(height: 20),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
IconButton(
icon: Icon(Icons.arrow_back,
color: Colors.white, size: 32),
onPressed: () {
Navigator.pop(context);
},
),
],
),
),
),
You need to wrap you Form widget with singleChildScroll view您需要使用 singleChildScroll 视图包装您的 Form 小部件
Like below return Scaffold( body: SingleChildScrollView(child:Form( key: _formKey, child: Container( child: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/login.jpg"), fit: BoxFit.contain, alignment: Alignment.topCenter)), child: SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ SizedBox(height: 20), Expanded( child: Container( padding: EdgeInsets.symmetric(horizontal: 40), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ IconButton( icon: Icon(Icons.arrow_back, color: Colors.white, size: 32), onPressed: () { Navigator.pop(context); }, ), ], ), ), ), )
像下面
return Scaffold( body: SingleChildScrollView(child:Form( key: _formKey, child: Container( child: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/login.jpg"), fit: BoxFit.contain, alignment: Alignment.topCenter)), child: SafeArea( child: Column( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ SizedBox(height: 20), Expanded( child: Container( padding: EdgeInsets.symmetric(horizontal: 40), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ IconButton( icon: Icon(Icons.arrow_back, color: Colors.white, size: 32), onPressed: () { Navigator.pop(context); }, ), ], ), ), ), )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.