@@ -802,15 +802,13 @@ class ResizeImageKey {
802802 this ._width,
803803 this ._height,
804804 this ._allowUpscaling,
805- this ._devicePixelRatio,
806805 );
807806
808807 final Object _providerCacheKey;
809808 final ResizeImagePolicy _policy;
810809 final int ? _width;
811810 final int ? _height;
812811 final bool _allowUpscaling;
813- final double _devicePixelRatio;
814812
815813 @override
816814 bool operator == (Object other) {
@@ -822,13 +820,11 @@ class ResizeImageKey {
822820 other._policy == _policy &&
823821 other._width == _width &&
824822 other._height == _height &&
825- other._allowUpscaling == _allowUpscaling &&
826- other._devicePixelRatio == _devicePixelRatio;
823+ other._allowUpscaling == _allowUpscaling;
827824 }
828825
829826 @override
830- int get hashCode =>
831- Object .hash (_providerCacheKey, _policy, _width, _height, _allowUpscaling, _devicePixelRatio);
827+ int get hashCode => Object .hash (_providerCacheKey, _policy, _width, _height, _allowUpscaling);
832828}
833829
834830/// Configures the behavior for [ResizeImage] .
@@ -1237,8 +1233,8 @@ enum ResizeImagePolicy {
12371233/// These values also set the image's width & height in logical pixels
12381234/// if it is unconstrained.
12391235///
1240- /// If [useLogicalPixels] is true, [ width] and [height] are multiplied by
1241- /// the device's pixel ratio at decode time.
1236+ /// [ width] and [height] are specified in logical pixels and multiplied by
1237+ /// [ImageConfiguration.devicePixelRatio] at decode time.
12421238///
12431239/// {@tool snippet}
12441240/// This example shows how to size the image to half of the screen's width.
@@ -1272,7 +1268,6 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
12721268 this .height,
12731269 this .policy = ResizeImagePolicy .exact,
12741270 this .allowUpscaling = false ,
1275- this .useLogicalPixels = false ,
12761271 }) : assert (width != null || height != null );
12771272
12781273 /// The [ImageProvider] that this class wraps.
@@ -1281,11 +1276,17 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
12811276 /// The width the image should decode to and cache.
12821277 ///
12831278 /// At least one of this and [height] must be non-null.
1279+ ///
1280+ /// This value is in logical pixels and is multiplied by
1281+ /// [ImageConfiguration.devicePixelRatio] at decode time.
12841282 final int ? width;
12851283
12861284 /// The height the image should decode to and cache.
12871285 ///
12881286 /// At least one of this and [width] must be non-null.
1287+ ///
1288+ /// This value is in logical pixels and is multiplied by
1289+ /// [ImageConfiguration.devicePixelRatio] at decode time.
12891290 final int ? height;
12901291
12911292 /// The policy that determines how [width] and [height] are interpreted.
@@ -1302,31 +1303,18 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
13021303 /// to use an appropriate [Image.fit] .
13031304 final bool allowUpscaling;
13041305
1305- /// Whether to treat [width] and [height] as logical pixels.
1306- ///
1307- /// When true, [width] and [height] are multiplied by
1308- /// [ImageConfiguration.devicePixelRatio] at decode time.
1309- final bool useLogicalPixels;
1310-
13111306 /// Composes the `provider` in a [ResizeImage] only when `cacheWidth` and
13121307 /// `cacheHeight` are not both null.
13131308 ///
13141309 /// When `cacheWidth` and `cacheHeight` are both null, this will return the
1315- /// `provider` directly. If `useLogicalPixels` is true, the dimensions are
1316- /// multiplied by the device's pixel ratio at decode time.
1310+ /// `provider` directly.
13171311 static ImageProvider <Object > resizeIfNeeded (
13181312 int ? cacheWidth,
13191313 int ? cacheHeight,
1320- ImageProvider <Object > provider, {
1321- bool useLogicalPixels = false ,
1322- }) {
1314+ ImageProvider <Object > provider,
1315+ ) {
13231316 if (cacheWidth != null || cacheHeight != null ) {
1324- return ResizeImage (
1325- provider,
1326- width: cacheWidth,
1327- height: cacheHeight,
1328- useLogicalPixels: useLogicalPixels,
1329- );
1317+ return ResizeImage (provider, width: cacheWidth, height: cacheHeight);
13301318 }
13311319 return provider;
13321320 }
@@ -1337,9 +1325,8 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
13371325 'This feature was deprecated after v3.7.0-1.4.pre.' ,
13381326 )
13391327 ImageStreamCompleter loadBuffer (ResizeImageKey key, DecoderBufferCallback decode) {
1340- final double devicePixelRatio = useLogicalPixels ? key._devicePixelRatio : 1.0 ;
1341- final int ? effectiveWidth = width != null ? (width! * devicePixelRatio).ceil () : null ;
1342- final int ? effectiveHeight = height != null ? (height! * devicePixelRatio).ceil () : null ;
1328+ final int ? effectiveWidth = key._width;
1329+ final int ? effectiveHeight = key._height;
13431330
13441331 Future <ui.Codec > decodeResize (
13451332 ui.ImmutableBuffer buffer, {
@@ -1373,9 +1360,8 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
13731360
13741361 @override
13751362 ImageStreamCompleter loadImage (ResizeImageKey key, ImageDecoderCallback decode) {
1376- final double devicePixelRatio = useLogicalPixels ? key._devicePixelRatio : 1.0 ;
1377- final int ? effectiveWidth = width != null ? (width! * devicePixelRatio).ceil () : null ;
1378- final int ? effectiveHeight = height != null ? (height! * devicePixelRatio).ceil () : null ;
1363+ final int ? effectiveWidth = key._width;
1364+ final int ? effectiveHeight = key._height;
13791365
13801366 Future <ui.Codec > decodeResize (
13811367 ui.ImmutableBuffer buffer, {
@@ -1468,9 +1454,9 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
14681454
14691455 @override
14701456 Future <ResizeImageKey > obtainKey (ImageConfiguration configuration) {
1471- final double devicePixelRatio = useLogicalPixels
1472- ? (configuration.devicePixelRatio ?? 1.0 )
1473- : 1.0 ;
1457+ final double devicePixelRatio = configuration.devicePixelRatio ?? 1.0 ;
1458+ final int ? effectiveWidth = width != null ? (width ! * devicePixelRatio). ceil () : null ;
1459+ final int ? effectiveHeight = height != null ? (height ! * devicePixelRatio). ceil () : null ;
14741460 Completer <ResizeImageKey >? completer;
14751461 // If the imageProvider.obtainKey future is synchronous, then we will be able to fill in result with
14761462 // a value before completer is initialized below.
@@ -1480,12 +1466,12 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
14801466 // This future has completed synchronously (completer was never assigned),
14811467 // so we can directly create the synchronous result to return.
14821468 result = SynchronousFuture <ResizeImageKey >(
1483- ResizeImageKey ._(key, policy, width, height , allowUpscaling, devicePixelRatio ),
1469+ ResizeImageKey ._(key, policy, effectiveWidth, effectiveHeight , allowUpscaling),
14841470 );
14851471 } else {
14861472 // This future did not synchronously complete.
14871473 completer.complete (
1488- ResizeImageKey ._(key, policy, width, height , allowUpscaling, devicePixelRatio ),
1474+ ResizeImageKey ._(key, policy, effectiveWidth, effectiveHeight , allowUpscaling),
14891475 );
14901476 }
14911477 });
@@ -1511,13 +1497,11 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
15111497 width == other.width &&
15121498 height == other.height &&
15131499 policy == other.policy &&
1514- allowUpscaling == other.allowUpscaling &&
1515- useLogicalPixels == other.useLogicalPixels;
1500+ allowUpscaling == other.allowUpscaling;
15161501 }
15171502
15181503 @override
1519- int get hashCode =>
1520- Object .hash (imageProvider, width, height, policy, allowUpscaling, useLogicalPixels);
1504+ int get hashCode => Object .hash (imageProvider, width, height, policy, allowUpscaling);
15211505}
15221506
15231507/// The strategy for [Image.network] and [NetworkImage] to decide whether to
0 commit comments