marker_widget 1.1.0
marker_widget: ^1.1.0 copied to clipboard
Render any Flutter widget into a google_maps_flutter BitmapDescriptor, with caching, proper pixel-ratio handling, and modern Flutter View APIs.
Changelog #
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.1.0 - 2025-12-04 #
Added #
MarkerIcon.toMapBitmap(): ReturnsBytesMapBitmapdirectly for users who need the concrete type for storage or interoperability.MarkerIcon.sizeInBytes: Getter for memory tracking.- Memory-based cache eviction: New
maxCacheBytesparameter (default 50 MB) onMarkerIconRendererto prevent unbounded memory growth. - Concurrent render deduplication: Multiple simultaneous calls with the same
cacheKeynow share a single render operation instead of duplicating work. - Cache introspection:
MarkerIconRenderer.cacheSize— current entry count.MarkerIconRenderer.cacheSizeInBytes— current memory usage.MarkerIconRenderer.isCached(key)— check if a key exists.MarkerIconRenderer.peekCache(key)— get without LRU bump.
- New extension methods on
Widget:toMapBitmap()— returnsBytesMapBitmapdirectly.toMarkerIcon()— returnsMarkerIconfor storage and later conversion.
- New standalone functions:
widgetToMapBitmap()— convenience withoutBuildContext, returnsBytesMapBitmap.widgetToMarkerIcon()— convenience withoutBuildContext, returnsMarkerIcon.
@immutableannotation onMarkerIconfor correctness.- Enhanced documentation: Added "Render Once, Reuse Everywhere" pattern examples in README and class docs.
Changed #
MapBitmapScaling.nonevalidation: Now throwsStateErrorfor both scaling modes (not justimagePixelRatio). This was already invalid at the platform level; the error message is now clearer and fails earlier.- Improved code style: explicit type annotations throughout for better readability.
- Updated README with performance tips, memory management guidance, and static vs dynamic marker strategies.
1.0.0 - 2025-11-24 #
Added #
- Initial release of marker_widget.
- Off-screen renderer that converts any
Widgetinto PNG bytes using:RenderView+ViewConfigurationwith logical & physical constraints.RepaintBoundaryand explicitPipelineOwner/BuildOwnerlifecycle.
MarkerIconvalue object that encapsulates:- PNG bytes.
- Logical size.
- Device pixel ratio.
- Conversion to
BitmapDescriptor.byteswithMapBitmapScaling.
MarkerIconRenderer:- Configurable default logical size.
- Optional LRU-based in-memory cache with size limit.
- Optional image-aware second pass via
waitForImages.
MarkerIconScalingMode:logicalSizemode (stable logical size, default).imagePixelRatiomode (pixel-perfect usingimagePixelRatio).
WidgetMarkerExtension.toMarkerBitmap:- Convert any widget into a
BitmapDescriptorusing the default (or injected) renderer. - Supports
waitForImages, custom pixel ratio, bitmap scaling, and scaling mode.
- Convert any widget into a
- Top-level
widgetToMarkerBitmaphelper for use without aBuildContext. buildMarkerCacheKeyhelper for theme/locale/size-aware marker caching.- Example app demonstrating:
- Basic usage with a custom card-like marker.
- Toggling between logical-size and image-pixel-ratio scaling modes.