Image class

A component that displays an image.

Example

Image(
  'https://example.com/image.png',
  alt: 'Image',
  size: SizeConstraints(
    width: Dim.px(100),
    height: Dim.px(100),
  ),
  cache: true,
  lazyLoad: true,
  fit: ObjectFit.cover,
)
Mixed-in types

Constructors

Image(String src, {Key? key, bool lazyLoad = false, bool cache = false, ObjectPosition position = ObjectPosition.center, ObjectFit? fit, SizeConstraints? size, String? alt, Color? backgroundColor, Gradient? gradient, BorderRadiusData? radius, EdgeInsets? padding, String? classes})
A component that displays an image.
const

Properties

alt → String?
Semantic description of the image for accessibility.
final
backgroundColor → Color?
Background color applied to the image container.
final
cache → bool
When true and src is a remote URL, the image will be cached. Future rendering will use the cached source provided that cache is enabled.
final
classes → String?
Additional CSS classes applied to the image.
final
fit → ObjectFit?
How to inscribe the image into the space allocated.
final
gradient → Gradient?
Background gradient applied to the image container.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one component replaces another component in the tree.
finalinherited
lazyLoad → bool
When true, image loading will be deferred until it is scrolled into view.
final
padding → EdgeInsets?
Padding applied to the image container when backgroundColor or gradient is set.
final
position → ObjectPosition
Defines the alignment of the image within its container.
final
radius → BorderRadiusData?
Radius of the image corners.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → SizeConstraints?
Image size.
final
src → String
Image source can be a remote url, base64 encoded string or an asset path.
final

Methods

afterRender(BuildContext context) → FutureOr<VoidCallback?>
This method is called only once after the component is built and the browser has rendered it. Does nothing on server rendering.
override
build(BuildContext context) → Component
Describes the part of the user interface represented by this component.
createElement() → Element
Creates a StatelessElement to manage this component's location in the tree.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRebuild(covariant Component newComponent) → bool
Implement this method to determine whether a rebuild can be skipped.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited