DVImageVariants class

The widths images are resized to, and what can be resized.

Read from dartvel.images in pubspec.yaml by the build, which adds what it knows about the build itself -- whether a server answers dvImageEndpointPath, and which images it wrote variants of -- and hands the whole of it to the application. An application built without it has no variants: isActive is false and every image is fetched as it is.

Constructors

DVImageVariants({List<int> widths = dvDefaultImageWidths, int quality = 75, List<String> remoteHosts = const <String>[], bool endpoint = false, Map<String, int> assetWidths = const <String, int>{}})
const

Properties

assetWidths → Map<String, int>
The width of each image the build wrote variants of, by the path the site serves it at (assets/assets/hero.png). A variant as wide as the image or wider is never written, so the image itself is used instead.
final
endpoint → bool
Whether a server answers dvImageEndpointPath: true on a web-server build, false on a static one, where there is nothing to answer it.
final
hashCode → int
The hash code for this object.
no setterinherited
isActive → bool
Whether this build has any variants at all.
no setter
quality → int
For lossy formats; 1 to 100.
final
remoteHosts → List<String>
Hosts whose images the server will fetch and resize. *.example.com allows the subdomains of example.com and not example.com itself.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
widths → List<int>
Ascending. A request for any other width is refused.
final

Methods

allowsHost(String host) → bool
Whether the server may fetch images from host.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
snap(double devicePixels) → int
The smallest configured width covering devicePixels, or the largest.
toDartDefine() → String
toJson as a --dart-define value: base64url, because the flutter tool splits a define's value at commas and a JSON object is full of them.
toJson() → Map<String, Object?>
toString() → String
A string representation of this object.
inherited
variantUrl(String src, double devicePixels) → String?
Where src drawn devicePixels wide is fetched from, or null to fetch src itself.

Operators

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

Static Methods

fromJson(Object? json) → DVImageVariants
What toJson wrote, as a map, as its JSON text or as toDartDefine's base64url. Anything unreadable is a build with no variants, never an exception: this runs as the application starts.
parse(Object? section) → ({List<String> problems, DVImageVariants variants})
dartvel.images from pubspec.yaml, and what in it was not accepted.