【问题标题】:Flutter - Bottom Overflowed By 119 Pixels [duplicate]Flutter - 底部溢出 119 个像素
【发布时间】:2019-06-06 23:02:30
【问题描述】:

在 ListView 中创建图像时出现错误“底部溢出 199 像素”,在我用谷歌搜索后,他们都建议我添加:

resizeToAvoidBottomPadding: false

但是,它不起作用!错误仍然存​​在。

SafeArea 小部件也不能解决问题。这是我的布局的简短代码版本:

body: ListView(
         children:<Widget> [
           new Container(
             child: new Stack(
               children:<Widget> [
                 //THE WIDGET
                 new Container(), //THE BACKGROND IMAGE
                 new Positioned(
                   child: Column(
                     children:<Widget>[
                         new Transform(),
                         new FadeTransition(),
                         new FadeTransition(),
                         Divider(),
                         new Row(),
                         //THE IMAGE THAT I WANT TO ADD
                         new Container(
                           height: 360.0
                           decoration: BoxDecoration(
                            image: DecorationImage(
                               image: Assetimage('lake.jpg)

【问题讨论】:

    标签: dart flutter


    【解决方案1】:

    使用 Scaffold 属性“resizeToAvoidBottomPadding: false”和“SingleChildScrollView”作为 Scaffold body 的父级:

        home: Scaffold(
              resizeToAvoidBottomInset : false,
              appBar: AppBar(
                title: Text("Registration Page"),
              ),
              body: SingleChildScrollView(
                child: RegisterUserPage(),
              )),
    

    【讨论】:

    • 非常感谢您的解决方案,它帮助很大!
    • 只有 resizeToAvoidBottomPadding: false 工作,因为我有定位设计。谢谢
    • 此属性已不存在,但此resizeToAvoidBottomInset 存在
    • 设置resizeToAvoidBottomInset = false(resizeToAvoidBottomPadding 已弃用。)
    【解决方案2】:

    将您的内容放入 SingleChildScrollView 并添加 ConstrainedBox,如下所示:

    body :SingleChildScrollView(
            child: ConstrainedBox(
              constraints: BoxConstraints(),
                child: ListView(
             children:<Widget> [
               new Container(
                 child: new Stack(
                   children:<Widget> [
                     //THE WIDGET
                     new Container(), //THE BACKGROND IMAGE
                     new Positioned(
                       child: Column(
                         children:<Widget>[
                             new Transform(),
                             new FadeTransition(),
                             new FadeTransition(),
                             Divider(),
                             new Row(),
                             //THE IMAGE THAT I WANT TO ADD
                             new Container(
                               height: 360.0
                               decoration: BoxDecoration(
                                image: DecorationImage(
                                   image: Assetimage('lake.jpg)
    

    这可能使您的屏幕可滚动,添加约束将使其有限滚动。

    【讨论】:

      【解决方案3】:

      没什么,只需将您的 widget 包含在 Expanded 中,就像这样

       Expanded(
          child: sectionList(),
        )
      

      //这解决了我的问题

      【讨论】:

        【解决方案4】:

        在 Scaffold 中使用 resizeToAvoidBottomInset: true, 并用 SingleChildScrollView 包裹身体中的第一个孩子解决了我的问题。

        【讨论】:

        • 谢谢!只用 SingleChildScrollView 包装第一个孩子对我来说是完美的
        【解决方案5】:

        脚手架中的参数对我有用,为这个错误包含你的小部件。 单子滚动视图

        【讨论】:

          【解决方案6】:

          随便用

          SingleChildScrollView()

          喜欢

                body: SingleChildScrollView(
                child:  Column(
                  children: [
                    widgetClassSectionButton(),
                    listAttandance.isNotEmpty ? headLineContainer() : msgNothingToShow(),
                    listAttandance.isNotEmpty ? widgetStudentList():widgetMsgEmpty(),
                    CustomButton("Submit Data",context)
                  ],
                ),
              )
          

          【讨论】:

            【解决方案7】:

            这将项目从下到上对齐:

            child: SizedBox(
                          height: MediaQuery.of(context).size.height,
                          child: SingleChildScrollView(
                            reverse: true,
            

            【讨论】:

              【解决方案8】:

              这适用于我的长格式:

              return Scaffold(
                resizeToAvoidBottomInset: true,
                body: SingleChildScrollView(
                  child: IntrinsicHeight(
                    child: Form(
                      key: _formKey,
                      child: Column(...
              

              【讨论】:

                【解决方案9】:

                这就是我解决它的方法,在 Scaffold() 内添加 resizeToAvoidBottomInset: false, 并在正文内使用 SingleChildScrollView()。

                 return Scaffold(
                      resizeToAvoidBottomInset: false,
                      backgroundColor: Colors.grey,
                      appBar: AppBar(
                        title: Text("Quotes"),
                        backgroundColor: Colors.green,
                      ),
                      body: SingleChildScrollView(
                        child: Column(
                          children: quotes.map((quote) => quotesTemplete(quote)).toList(),
                        ),
                      )
                    );
                

                【讨论】:

                  猜你喜欢
                  • 2019-03-12
                  • 1970-01-01
                  • 2021-06-21
                  • 2020-06-18
                  • 1970-01-01
                  • 1970-01-01
                  • 2021-05-23
                  • 2021-11-20
                  • 2021-11-08
                  相关资源
                  最近更新 更多