html_to_image_flutter 2.2.0 copy "html_to_image_flutter: ^2.2.0" to clipboard
html_to_image_flutter: ^2.2.0 copied to clipboard

Flutter plugin to convert HTML file to image on Android and iOS using WebView on Android and WkWebView on iOS.

html_to_image_flutter #

Flutter plugin to convert HTML content or HTML asset files to PNG image bytes using WebView on Android and WKWebView on iOS.

Requirements #

  • Android: Minimum SDK Version 21
  • iOS: Minimum Deployment Target 11.0

Usage #

Convert to Image from HTML content #

  • Future<Uint8List> convertToImage(String content, Duration delay,int? width)
final imageBytes = await HtmlToImage.convertToImage(
  content: content,
);
final image = Image.memory(imageBytes);

Convert to Image from HTML asset #

  • Future<Uint8List> convertToImageFromAsset(String asset, Duration delay,int? width)
final imageBytes = await HtmlToImage.convertToImageFromAsset(
  asset: 'assets/example.html',
);
final image = Image.memory(imageBytes);

Offline support #

html_to_image_flutter renders HTML passed from Dart directly inside the native WebView, so plain HTML strings and bundled Flutter assets can be converted while the device is offline.

For fully offline output, keep all required CSS, fonts, and images available locally:

final imageBytes = await HtmlToImage.convertToImage(
  content: '''
    <div style="padding:16px;font-family:Arial;background:white;color:#111">
      <h1>Offline receipt</h1>
      <p>This HTML does not require network access.</p>
    </div>
  ''',
  width: 360,
);

Recommended offline patterns:

  • Inline critical CSS in the HTML.

  • Use convertToImageFromAsset for bundled HTML templates.

  • Use base64/data URI images or local asset content injected into the HTML.

  • Avoid depending on remote image, font, or stylesheet URLs when deterministic offline captures are required.

  • Default delay is 200 milliseconds

  • Default width is device width

0
likes
140
points
361
downloads
screenshot

Documentation

Documentation
API reference

Publisher

verified publishercodingislife.net

Weekly Downloads

Flutter plugin to convert HTML file to image on Android and iOS using WebView on Android and WkWebView on iOS.

Homepage
Repository (GitHub)
View/report issues

Topics

#html #html-to-image #html-print

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on html_to_image_flutter

Packages that implement html_to_image_flutter