简体   繁体   English

Flutter:图像溢出

[英]Flutter : image overflow

can i solve this overflow when import big image?导入大图像时可以解决这个溢出问题吗? I am working on an interface project only and I want to solve this problem when importing a large image我正在做一个界面项目,我想在导入大图像时解决这个问题

change this:改变这个:

改变这个

to this:对此:

这个

my code:我的代码:

Scaffold(
        backgroundColor: Color(0xff131517),
        appBar : AppBar(),
        body: SafeArea(
          child: Directionality(
            textDirection: TextDirection.rtl,
            child: Column(
              children: [
                SizedBox(height: 10,),
                Container(child: Image.file(_image! , fit: BoxFit.contain , width: MediaQuery.of(context).size.width,)),
                Spacer(),
                Container(
                  height: 85,
                  color:Color(0xff1e1f23),
                  child: Center(
                    child: ListView(
                      scrollDirection: Axis.horizontal,
                      children: [],
                    ),
                  ),
                )
              ],
            )
          ),
        ),

You need to constrain the height of the container the image is in (or of the image itself) like so:您需要像这样限制图像所在容器(或图像本身)的高度:

Scaffold(
        backgroundColor: Color(0xff131517),
        appBar : AppBar(),
        body: SafeArea(
          child: Directionality(
            textDirection: TextDirection.rtl,
            child: Column(
              children: [
                SizedBox(height: 10,),
                Container(
                  height: MediaQuery.of(context).size.height*0.9,
                  child: Image.file(
                    _image!,
                     fit: BoxFit.contain,
                     width: MediaQuery.of(context).size.width,
                    )
                ),
                Spacer(),
                Container(
                  height: 85,
                  color:Color(0xff1e1f23),
                  child: Center(
                    child: ListView(
                      scrollDirection: Axis.horizontal,
                      children: [],
                    ),
                  ),
                )
              ],
            )
          ),
        ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM