A widget that displays an image.
Several constructors are provided for the various ways that an image can be specified:
- new Image, for obtaining an image from an ImageProvider.
- new Image.asset, for obtaining an image from an AssetBundle using a key.
- new Image.network, for obtaining an image from a URL.
- new Image.file, for obtaining an image from a File.
To automatically perform pixel-density-aware asset resolution, specify the
image using an AssetImage and make sure that a MaterialApp
, WidgetsApp,
or MediaQuery widget exists above the Image widget in the widget tree.
The image is painted using paintImage, which describes the meanings of the various fields on this class in more detail.
See also:
Icon
- Inheritance
- Object
- Widget
- StatefulWidget
- Image
Constructors
- Image({Key key, @required ImageProvider image, double width, double height, Color color, ImageFit fit, FractionalOffset alignment, ImageRepeat repeat: ImageRepeat.noRepeat, Rect centerSlice, bool gaplessPlayback: false })
-
Creates a widget that displays an image.
- Image.asset(String name, { Key key, AssetBundle bundle, double scale, double width, double height, Color color, ImageFit fit, FractionalOffset alignment, ImageRepeat repeat: ImageRepeat.noRepeat, Rect centerSlice, bool gaplessPlayback: false })
-
Creates a widget that displays an ImageStream obtained from an asset bundle. The key for the image is given by the
name
argument. - Image.file(File file, { Key key, double scale: 1.0, double width, double height, Color color, ImageFit fit, FractionalOffset alignment, ImageRepeat repeat: ImageRepeat.noRepeat, Rect centerSlice, bool gaplessPlayback: false })
-
Creates a widget that displays an ImageStream obtained from a File.
- Image.network(String src, { Key key, double scale: 1.0, double width, double height, Color color, ImageFit fit, FractionalOffset alignment, ImageRepeat repeat: ImageRepeat.noRepeat, Rect centerSlice, bool gaplessPlayback: false })
-
Creates a widget that displays an ImageStream obtained from the network.
Properties
- alignment → FractionalOffset
-
How to align the image within its bounds.
read-only - centerSlice → Rect
-
The center slice for a nine-patch image.
read-only - color → Color
-
If non-null, apply this color filter to the image before painting.
read-only - fit → ImageFit
-
How to inscribe the image into the space allocated during layout.
read-only - gaplessPlayback → bool
-
Whether to continue showing the old image (true), or briefly show nothing (false), when the image provider changes.
read-only - height → double
-
If non-null, require the image to have this height.
read-only - image → ImageProvider
-
The image to display.
read-only - repeat → ImageRepeat
-
How to paint any portions of the layout bounds not covered by the image.
read-only - width → double
-
If non-null, require the image to have this width.
read-only - hashCode → int
-
Get a hash code for this object.
read-only, inherited - key → Key
-
Controls how one widget replaces another widget in the tree.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
createState(
) → _ImageState -
Creates the mutable state for this widget at a given location in the tree.
-
debugFillDescription(
List<String> description) → void -
Add additional information to the given description for use by
toString
. -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited -
toStringShort(
) → String -
A short, textual description of this widget.
inherited