Document scale parameter for Image and RawImage (#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)).

#148623
This commit is contained in:
RamonFarizel
2024-08-22 13:42:18 -03:00
committed by GitHub
parent 4a6fbef83f
commit ef098c2aa4
2 changed files with 24 additions and 2 deletions

View File

@@ -5957,6 +5957,10 @@ class RichText extends MultiChildRenderObjectWidget {
/// expected to call [dart:ui.Image.dispose] on the [image] once the [RawImage]
/// is no longer buildable.
///
/// 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.
/// {@macro flutter.painting.imageInfo.scale}
///
/// This widget is rarely used directly. Instead, consider using [Image].
class RawImage extends LeafRenderObjectWidget {
/// Creates a widget that displays an image.
@@ -6005,9 +6009,11 @@ class RawImage extends LeafRenderObjectWidget {
/// aspect ratio.
final double? height;
/// Specifies the image's scale.
/// The linear scale factor for drawing this image at its intended size.
///
/// Used when determining the best display size for the image.
/// The scale factor applies to the width and the height.
///
/// {@macro flutter.painting.imageInfo.scale}
final double scale;
/// If non-null, this color is blended with each image pixel using [colorBlendMode].

View File

@@ -339,6 +339,10 @@ class Image extends StatefulWidget {
/// To show an image from the network or from an asset bundle, consider using
/// [Image.network] and [Image.asset] respectively.
///
/// 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.
/// {@macro flutter.painting.imageInfo.scale}
///
/// Either the [width] and [height] arguments should be specified, or the
/// widget should be placed in a context that sets tight layout constraints.
/// Otherwise, the image dimensions will change as the image is loaded, which
@@ -379,6 +383,10 @@ class Image extends StatefulWidget {
/// Otherwise, the image dimensions will change as the image is loaded, which
/// will result in ugly layout changes.
///
/// 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.
/// {@macro flutter.painting.imageInfo.scale}
///
/// All network images are cached regardless of HTTP headers.
///
/// An optional [headers] argument can be used to send custom HTTP headers
@@ -428,6 +436,10 @@ class Image extends StatefulWidget {
/// Creates a widget that displays an [ImageStream] obtained from a [File].
///
/// 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.
/// {@macro flutter.painting.imageInfo.scale}
///
/// Either the [width] and [height] arguments should be specified, or the
/// widget should be placed in a context that sets tight layout constraints.
/// Otherwise, the image dimensions will change as the image is loaded, which
@@ -508,6 +520,10 @@ class Image extends StatefulWidget {
/// If the `bundle` argument is omitted or null, then the
/// [DefaultAssetBundle] will be used.
///
/// 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.
/// {@macro flutter.painting.imageInfo.scale}
///
/// By default, the pixel-density-aware asset resolution will be attempted. In
/// addition:
///