Skip to content

Commit ef098c2

Browse files
authored
Document scale parameter for Image and RawImage (flutter#153728)
This PR documents the scale parameter for Image and RawImage. It adds the quote from the [Image.memory](https://main-api.flutter.dev/flutter/widgets/Image/Image.memory.html) for other constructors like: `Image.asset`, `Image.new`, `Image.network`, `Image.file` and `RawImage` > The scale argument specifies the linear scale factor for drawing this image at its intended size and applies to both the width and the height. For example, if this is 2.0, it means that there are four image pixels for every one logical pixel, and the image's actual width and height (as given by the [dart:ui.Image.width](https://main-api.flutter.dev/flutter/dart-ui/Image/width.html) and [dart:ui.Image.height](https://main-api.flutter.dev/flutter/dart-ui/Image/height.html) properties) are double the height and width that should be used when painting the image (e.g. in the arguments given to [Canvas.drawImage](https://main-api.flutter.dev/flutter/dart-ui/Canvas/drawImage.html)). flutter#148623
1 parent 4a6fbef commit ef098c2

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

packages/flutter/lib/src/widgets/basic.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5957,6 +5957,10 @@ class RichText extends MultiChildRenderObjectWidget {
59575957
/// expected to call [dart:ui.Image.dispose] on the [image] once the [RawImage]
59585958
/// is no longer buildable.
59595959
///
5960+
/// The `scale` argument specifies the linear scale factor for drawing this
5961+
/// image at its intended size and applies to both the width and the height.
5962+
/// {@macro flutter.painting.imageInfo.scale}
5963+
///
59605964
/// This widget is rarely used directly. Instead, consider using [Image].
59615965
class RawImage extends LeafRenderObjectWidget {
59625966
/// Creates a widget that displays an image.
@@ -6005,9 +6009,11 @@ class RawImage extends LeafRenderObjectWidget {
60056009
/// aspect ratio.
60066010
final double? height;
60076011

6008-
/// Specifies the image's scale.
6012+
/// The linear scale factor for drawing this image at its intended size.
6013+
///
6014+
/// The scale factor applies to the width and the height.
60096015
///
6010-
/// Used when determining the best display size for the image.
6016+
/// {@macro flutter.painting.imageInfo.scale}
60116017
final double scale;
60126018

60136019
/// If non-null, this color is blended with each image pixel using [colorBlendMode].

packages/flutter/lib/src/widgets/image.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ class Image extends StatefulWidget {
339339
/// To show an image from the network or from an asset bundle, consider using
340340
/// [Image.network] and [Image.asset] respectively.
341341
///
342+
/// The `scale` argument specifies the linear scale factor for drawing this
343+
/// image at its intended size and applies to both the width and the height.
344+
/// {@macro flutter.painting.imageInfo.scale}
345+
///
342346
/// Either the [width] and [height] arguments should be specified, or the
343347
/// widget should be placed in a context that sets tight layout constraints.
344348
/// Otherwise, the image dimensions will change as the image is loaded, which
@@ -379,6 +383,10 @@ class Image extends StatefulWidget {
379383
/// Otherwise, the image dimensions will change as the image is loaded, which
380384
/// will result in ugly layout changes.
381385
///
386+
/// The `scale` argument specifies the linear scale factor for drawing this
387+
/// image at its intended size and applies to both the width and the height.
388+
/// {@macro flutter.painting.imageInfo.scale}
389+
///
382390
/// All network images are cached regardless of HTTP headers.
383391
///
384392
/// An optional [headers] argument can be used to send custom HTTP headers
@@ -428,6 +436,10 @@ class Image extends StatefulWidget {
428436

429437
/// Creates a widget that displays an [ImageStream] obtained from a [File].
430438
///
439+
/// The `scale` argument specifies the linear scale factor for drawing this
440+
/// image at its intended size and applies to both the width and the height.
441+
/// {@macro flutter.painting.imageInfo.scale}
442+
///
431443
/// Either the [width] and [height] arguments should be specified, or the
432444
/// widget should be placed in a context that sets tight layout constraints.
433445
/// Otherwise, the image dimensions will change as the image is loaded, which
@@ -508,6 +520,10 @@ class Image extends StatefulWidget {
508520
/// If the `bundle` argument is omitted or null, then the
509521
/// [DefaultAssetBundle] will be used.
510522
///
523+
/// The `scale` argument specifies the linear scale factor for drawing this
524+
/// image at its intended size and applies to both the width and the height.
525+
/// {@macro flutter.painting.imageInfo.scale}
526+
///
511527
/// By default, the pixel-density-aware asset resolution will be attempted. In
512528
/// addition:
513529
///

0 commit comments

Comments
 (0)