'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: [],
),
),
)
],
)
),
),
Solution 1:[1]
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: [],
),
),
)
],
)
),
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ranvir Mohanlal |


