Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BoxDecoration doesn't respect repeatX/repeatY when fitWidth/fitHeight is used. #117183

Closed
@stereotype441

Description

@stereotype441

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Look at the screen

Expected results:

Since the source image has a wider aspect ratio than the BoxDecoration, and fitWidth is used in combination with repeatY, I would expect the image to be repeated vertically, like this:

image

Actual results:

Instead the image is drawn only once:

image

(Note that if BoxFit.fitWidth is changed to BoxFit.contain, then I get the expected behaviour in this example. But BoxFit.contain only fits the width if the source image has a wider aspect ratio than the BoxDecoration; I want to fit the width regardless of the aspect ratios).

A similar problem exists between fitHeight and repeatX (though to see it you'll have to modify the aspect ratios in my example program).

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(
    FittedBox(
      child: Container(
        width: 100,
        height: 200,
        decoration: const BoxDecoration(
          color: Colors.white,
          image: DecorationImage(
            image: NetworkImage(
                'https://docs.flutter.dev/assets/images/shared/brand/flutter/logo/flutter-lockup.png'),
            fit: BoxFit.fitWidth,
            repeat: ImageRepeat.repeatY,
          ),
        ),
      ),
    ),
  );
}

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listfound in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions