Closed
Description
Steps to Reproduce
- Execute
flutter run
on the code sample - 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:
Actual results:
Instead the image is drawn only once:
(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,
),
),
),
),
);
}