Image class

{{template flint_image} A versatile image widget in Flint UI, designed for rendering images in multiple formats including HTML (for emails and web) and plain text.

The Image class provides flexible styling options such as margins, padding, borders, shadows, captions, and lazy-loading support.

It can optionally wrap the image inside a link or display a caption below it, using semantic HTML elements like <a> and <figure>.

Example:

Image(
  src: 'https://flintdart.dev/logo.png',
  alt: 'Flint Dart Logo',
  width: 120,
  caption: 'Powered by Flint Dart',
  lazyLoading: true,
)

This will render as an HTML image with a caption underneath and lazy loading enabled. {{endtemplate}

Inheritance

Constructors

Image({required String src, String? alt, double? width, double? height, EdgeInsets? margin, EdgeInsets? padding, String? alignment, BoxBorder? border, BorderRadius? borderRadius, BoxShadow? shadow, ImageStyle style = const ImageStyle(), String? caption, bool lazyLoading = false, String? linkUrl})
Creates a Image widget.

Properties

alignment String?
The image alignment, represented as a string (e.g., "left", "center", "right").
final
alt String?
The alternative text for the image, used for accessibility and when the image fails to load.
final
border BoxBorder?
The border style of the image, defined using BoxBorder.
final
borderRadius BorderRadius?
The radius of the image corners.
final
caption String?
A text caption displayed below the image.
final
directives Map<String, String>
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
height double?
The explicit height of the image in pixels.
final
id String
finalinherited
lazyLoading bool
Whether to enable native browser lazy-loading for the image.
final
linkUrl String?
An optional hyperlink URL that wraps the image.
final
margin EdgeInsets?
The margin applied outside the image container.
final
padding EdgeInsets?
The padding applied inside the image container.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
script FlintScript?
finalinherited
shadow BoxShadow?
The shadow applied to the image.
final
src String
The source URL or path of the image.
final
style ImageStyle
Additional visual options for the image, defined via ImageStyle.
final
width double?
The explicit width of the image in pixels.
final
xBind Map<String, String>
finalinherited
xCloak bool?
finalinherited
xData String?
finalinherited
xEffect String?
finalinherited
xFor String?
finalinherited
xHtml String?
finalinherited
xId String?
finalinherited
xIf bool?
finalinherited
xIgnore bool?
finalinherited
xInit String?
finalinherited
xModel String?
finalinherited
xModelable String?
finalinherited
xOn Map<String, String>
finalinherited
xRef String?
finalinherited
xShow String?
finalinherited
xTeleport String?
finalinherited
xText String?
finalinherited
xTransition String?
finalinherited

Methods

buildTemplate() FlintWidget
{{macro flint_widget.buildTemplate}
override
copyWith({String? src, String? alt, double? width, double? height, EdgeInsets? margin, EdgeInsets? padding, String? alignment, BoxBorder? border, BorderRadius? borderRadius, BoxShadow? shadow, ImageStyle? style, String? caption, bool? lazyLoading, String? linkUrl}) Image
Creates a copy of this image with updated properties.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
renderAttributes({String? style}) String
---------------- Helper ---------------- Converts ID + directives + optional style to HTML attributes
inherited
renderScriptAttributes() String
Render attached script to HTML attributes
inherited
toHtml() String
Converts this image into an HTML representation.
override
toJson() Map<String, dynamic>
Serializes this image into a JSON-compatible map.
override
toString() String
A string representation of this object.
inherited
toText() String
Converts this image into a plain-text description.
override

Operators

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