簡體   English   中英

Android Flutter:我需要在正文中設置“SingleChildScrollView”?

[英]Android Flutter : I need to set the 'SingleChildScrollView' in the body?

這是我的代碼,我需要在正文中設置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);
                            },
                          ),
                        ],
                      ),
                    ),
                  ),

您需要使用 singleChildScroll 視圖包裝您的 Form 小部件

像下面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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM