简体   繁体   中英

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: [],
                    ),
                  ),
                )
              ],
            )
          ),
        ),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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