in this code i have to fit image into container. but not chnage any widget it is same only image fit in container.
body:
GestureDetector(
onScaleStart: (details) {
_previousScale = _scale;
},
onScaleUpdate: (details) {
setState(() {
_scale = _previousScale * details.scale;
});
},
onDoubleTap: () {
setState(() {
_scale = (_scale == 1.0) ? 2.0 : 1.0;
});
},
child: Transform(
alignment: FractionalOffset.center,
transform: Matrix4.diagonal3Values(_scale, _scale, 1.0),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: AspectRatio(
aspectRatio: 5 / 7,
child: Container(
color: Colors.black,
alignment: isKeyboardVisible
? Alignment.topCenter
: Alignment.center,
width: double.infinity,
height: double.infinity,
child: AspectRatio(
aspectRatio: 5 / 7,
child: Stack(
children: [
Hero(
tag: "${widget.index}",
child: Image.asset(
"images/${widget.index}.png",
fit: BoxFit.cover,
),
),
...movableTextWidgets,
],
),
),
),
),
),
)
what wrong in this code? enter image description here in this image black color is container and the white is image but not fit in container.
Try this out and set your height and width to container