11part of 'overlay_image_layer.dart' ;
22
3- /// Base class for all overlay images.
3+ /// Display an [Image] on the map at a specific coordinate location, within an
4+ /// [OverlayImageLayer]
5+ ///
6+ /// Implemented by [OverlayImage] & [RotatedOverlayImage] .
47@immutable
5- sealed class BaseOverlayImage extends StatelessWidget {
6- /// The [ImageProvider] for the image .
8+ abstract class BaseOverlayImage extends StatelessWidget {
9+ /// The [ImageProvider] to use within the [Image] widget .
710 final ImageProvider imageProvider;
811
912 /// The opacity in which the image should get rendered on the map.
@@ -17,6 +20,7 @@ sealed class BaseOverlayImage extends StatelessWidget {
1720 /// overlay image should have on the map.
1821 final FilterQuality filterQuality;
1922
23+ /// Display an [Image] on the map at a specific coordinate location
2024 const BaseOverlayImage ({
2125 super .key,
2226 required this .imageProvider,
@@ -25,25 +29,29 @@ sealed class BaseOverlayImage extends StatelessWidget {
2529 this .filterQuality = FilterQuality .medium,
2630 });
2731
28- Widget _render (
32+ /// Given the [child] image to display, return the layout (ie. position &
33+ /// transformation) of the child
34+ ///
35+ /// Use [MapCamera.of] to retrieve the ambient [MapCamera] useful for layout.
36+ ///
37+ /// If more control over the [Image] itself is required, prefer subclassing
38+ /// one of the existing subclasses and overriding [build] .
39+ @protected
40+ Widget layout (
2941 BuildContext context, {
3042 required Image child,
31- required MapCamera camera,
3243 });
3344
3445 @override
35- @nonVirtual
36- Widget build (BuildContext context) => _render (
46+ Widget build (BuildContext context) => layout (
3747 context,
3848 child: Image (
3949 image: imageProvider,
4050 fit: BoxFit .fill,
41- color: Color .fromRGBO (255 , 255 , 255 , opacity),
42- colorBlendMode: BlendMode .modulate,
51+ opacity: AlwaysStoppedAnimation (opacity),
4352 gaplessPlayback: gaplessPlayback,
4453 filterQuality: filterQuality,
4554 ),
46- camera: MapCamera .of (context),
4755 );
4856}
4957
@@ -67,11 +75,12 @@ class OverlayImage extends BaseOverlayImage {
6775 });
6876
6977 @override
70- Widget _render (
78+ Widget layout (
7179 BuildContext context, {
7280 required Image child,
73- required MapCamera camera,
7481 }) {
82+ final camera = MapCamera .of (context);
83+
7584 // northWest is not necessarily upperLeft depending on projection
7685 final bounds = Bounds <double >(
7786 camera.project (this .bounds.northWest) - camera.pixelOrigin,
@@ -120,11 +129,12 @@ class RotatedOverlayImage extends BaseOverlayImage {
120129 });
121130
122131 @override
123- Widget _render (
132+ Widget layout (
124133 BuildContext context, {
125134 required Image child,
126- required MapCamera camera,
127135 }) {
136+ final camera = MapCamera .of (context);
137+
128138 final pxTopLeft = camera.project (topLeftCorner) - camera.pixelOrigin;
129139 final pxBottomRight =
130140 camera.project (bottomRightCorner) - camera.pixelOrigin;
0 commit comments