Dartvel, home
Docs
Features
Studio
Cloud
Compared

Search the site

GitHub
pub.dev

GETTING STARTED

Getting started
Existing Flutter apps
Existing Native apps
Run on your phone

APP

UI and styling
Routing
State
Accessibility
Keyboard shortcuts
Localization
Devices and desktop
Native device access
Media, 3D and XR

DATA

Data models
Forms
Search
Sync and offline
Import and export
Change capture
Database
Cache
File storage
Images
Privacy and erasure

BACKEND

Backend functions
Auth and sessions
Authorization
Queues and jobs
Workers and memory
Notifications and mail
Outbound HTTP
AI
Webhooks
GraphQL and OpenAPI
API keys and OAuth
Multi-tenancy
Billing and commerce
Modules

OPERATIONS

Edge security
Secrets and environments
Monitoring
Releases

SHIPPING

Build targets
Telegram Mini Apps
Static web hosting
Servers and deploying

REFERENCE

Testing
CLI reference
Coding agents

DATA

Images

A phone downloads the 640-pixel image and a large screen gets the 1920, from one asset you declared.

The build writes the sizes, and DVBox.image asks for the one its slot needs.

ON THIS PAGE

Serve each image at the width it needs

Resize on request with web-server

Paint the image on the first frame

Status

Serve each image at the width it needs

# pubspec.yaml
dartvel:
  images:
    widths: [320, 640, 1080, 1920]
    quality: 75
    remoteHosts: [images.example.com]

Copy code to clipboard

Name the file through DVAsset, which dartvel routes generates from what your pubspec bundles. A renamed file then stops the build. With a path in a string it shows an empty box on somebody's phone.

Widget hero() => DVBox.image(
      // Generated from pubspec.yaml: a renamed file is a compile error, not a
      // blank box on somebody's phone.
      DVAsset.hero,
      alt: 'A team planning a release',
      width: 400,
      height: 210,
    );

Copy code to clipboard

The same asset behind a box, as a background:

Widget banner() => const DVBox(DVText('Now shipping')).modifier(
      const DVModifier().backgroundImage(DVAsset.hero).padding(48),
    );

Copy code to clipboard

dartvel build web writes each declared raster asset at every configured width narrower than the image.

DVBox.image asks for its laid-out width times the device pixel ratio, rounded up to a configured width.

Leave out widths and you get 16, then the default image and device sizes of Next.js 16, from 32 to 3840.

Resize on request with web-server

dartvel build web-server

Copy code to clipboard

The server answers /_dartvel/image, resizes on first request and caches the result.

A PNG or WebP source is sent as WebP to a browser that accepts it.

It refuses widths outside your list and hosts missing from remoteHosts.

Paint the image on the first frame

A link that prefetches its page also fetches the variant for the visitor's pixel ratio, into the cache the widget reads. The image is downloaded once and is there when the page opens.

GIFs are sent as they are

Resizing an animated GIF would keep only its first frame, so GIFs are never resized.

Status

Partial

Spec section: Media Pipeline

Planned work and implementation limits

Nothing for uploads: no resizing, validation or size limits for files users send.

No AVIF, and WebP only from a web-server build.

Variants are written for web builds only. Apps on devices ship their original assets.

No video processing.

PREVIOUS File storage Files on local disk, S3, GCS or Azure
NEXT Privacy and erasure Export and erase a person's data
GitHub
pub.dev
npm
Acknowledgements
Privacy
Terms

FSL-1.1-MIT licensed. Built with Dartvel.

Dartvel is made by

SigmaDev Digital

To the bottom