Skip to content

Document scale parameter for Image and RawImage #153728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/flutter/lib/src/widgets/basic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
///
/// The scale factor applies to the width and the height.
///
/// Used when determining the best display size for the image.
/// {@macro flutter.painting.imageInfo.scale}
final double scale;

/// If non-null, this color is blended with each image pixel using [colorBlendMode].
Expand Down
16 changes: 16 additions & 0 deletions packages/flutter/lib/src/widgets/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
///
Expand Down