Ten Digit Grid
Ten Digit Grid

Reputation: 2629

Flutter Image not shrinking when window gets smaller

I have a flutter image that is not shrinking as the window shrinks:

Widget build(BuildContext context) {
    return Expanded(
      flex: 1,
      child: Column(
        //mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          ConstrainedBox(
            constraints: const BoxConstraints(maxHeight: 500, maxWidth: 600),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(15.0),
              child: Image.asset(
                'images/DontForgetTheSpoon-largeLogo.jpg',
              ),
            ),
          ),

I tried to use boxFit.contain in the Image.Asset but that didn't seem to work out for me. Anything else I should be looking into?

This widget is inside other widgets just for SA.

Upvotes: 0

Views: 70

Answers (1)

Unknown Developer
Unknown Developer

Reputation: 167

Try to use fit property of image Widget, inorder to have image shrink try use value BoxFit.contain:

ClipRRect(
  borderRadius: BorderRadius.circular(15.0),
  child: Image.asset(
    'images/DontForgetTheSpoon-largeLogo.jpg',
    fit: BoxFit.contain,
  ),
),

Upvotes: 1

Related Questions