@@ -26,7 +26,7 @@ enum MapBitmapScaling {
26
26
///
27
27
/// This can be used if the image is already pre-scaled, or to increase
28
28
/// performance with a large numbers of markers.
29
- noScaling ,
29
+ none ,
30
30
}
31
31
32
32
// The default pixel ratio for custom bitmaps.
@@ -316,6 +316,29 @@ class BitmapDescriptor {
316
316
/// Represents a [BitmapDescriptor] base class for map bitmaps.
317
317
///
318
318
/// See [AssetMapBitmap] and [BytesMapBitmap] for concrete implementations.
319
+ ///
320
+ /// The [imagePixelRatio] should be set to the correct pixel ratio of bitmap
321
+ /// image. If the [width] or [height] is provided, the [imagePixelRatio]
322
+ /// value is ignored.
323
+ ///
324
+ /// [bitmapScaling] controls the scaling behavior:
325
+ /// - [MapBitmapScaling.auto] automatically upscales and downscales the image
326
+ /// to match the device's pixel ratio or the specified dimensions,
327
+ /// maintaining consistency across devices.
328
+ /// - [MapBitmapScaling.none] disables automatic scaling, which is
329
+ /// useful when performance is a concern or if the asset is already scaled
330
+ /// appropriately.
331
+ ///
332
+ /// Optionally, [width] and [height] can be specified to control the dimensions
333
+ /// of the rendered image:
334
+ /// - If both [width] and [height] are non-null, the image will have the
335
+ /// specified dimensions, which might distort the original aspect ratio,
336
+ /// similar to [BoxFit.fill] .
337
+ /// - If only one of [width] and [height] is non-null, then the output image
338
+ /// will be scaled to the associated width or height, and the other dimension
339
+ /// will take whatever value is needed to maintain the image's original aspect
340
+ /// ratio. These cases are similar to [BoxFit.fitWidth] and
341
+ /// [BoxFit.fitHeight] , respectively.
319
342
abstract class MapBitmap extends BitmapDescriptor {
320
343
MapBitmap ._({
321
344
required this .bitmapScaling,
@@ -328,12 +351,35 @@ abstract class MapBitmap extends BitmapDescriptor {
328
351
final MapBitmapScaling bitmapScaling;
329
352
330
353
/// The pixel ratio of the bitmap.
354
+ ///
355
+ /// If the [width] or [height] is provided, the [imagePixelRatio]
356
+ /// value is ignored.
331
357
final double imagePixelRatio;
332
358
333
359
/// The target width of the bitmap in logical pixels.
360
+ ///
361
+ /// - If [width] is provided and [height] is null, the image will be scaled to
362
+ /// the associated width, and the height will take whatever value is needed
363
+ /// to maintain the image's original aspect ratio. This is similar to
364
+ /// [BoxFit.fitWidth] .
365
+ /// - If both [width] and [height] are non-null, the image will have the
366
+ /// specified dimensions, which might distort the original aspect ratio,
367
+ /// similar to [BoxFit.fill] .
368
+ /// - If neither [width] nor [height] is provided, the image will be rendered
369
+ /// using the [imagePixelRatio] value.
334
370
final double ? width;
335
371
336
372
/// The target height of the bitmap in logical pixels.
373
+ ///
374
+ /// - If [height] is provided and [width] is null, the image will be scaled to
375
+ /// the associated height, and the width will take whatever value is needed
376
+ /// to maintain the image's original aspect ratio. This is similar to
377
+ /// [BoxFit.fitHeight] .
378
+ /// - If both [width] and [height] are non-null, the image will have the
379
+ /// specified dimensions, which might distort the original aspect ratio,
380
+ /// similar to [BoxFit.fill] .
381
+ /// - If neither [width] nor [height] is provided, the image will be rendered
382
+ /// using the [imagePixelRatio] value.
337
383
final double ? height;
338
384
}
339
385
@@ -375,10 +421,10 @@ abstract class MapBitmap extends BitmapDescriptor {
375
421
/// - If both [width] and [height] are non-null, the image will have the
376
422
/// specified dimensions, which might distort the original aspect ratio,
377
423
/// similar to [BoxFit.fill].
378
- /// - If only one of ` width` and ` height` is non-null, then the output image
424
+ /// - If only one of [ width] and [ height] is non-null, then the output image
379
425
/// will be scaled to the associated width or height, and the other dimension
380
426
/// will take whatever value is needed to maintain the image's original aspect
381
- /// ratio. These cases are simnilar to [BoxFit.fitWidth] and
427
+ /// ratio. These cases are similar to [BoxFit.fitWidth] and
382
428
/// [BoxFit.fitHeight], respectively.
383
429
///
384
430
/// ```dart
@@ -432,7 +478,7 @@ class AssetMapBitmap extends MapBitmap {
432
478
/// - [MapBitmapScaling.auto] automatically upscales and downscales the image
433
479
/// to match the device's pixel ratio or the specified dimensions,
434
480
/// maintaining consistency across devices.
435
- /// - [MapBitmapScaling.noScaling ] disables automatic scaling, which is
481
+ /// - [MapBitmapScaling.none ] disables automatic scaling, which is
436
482
/// useful when performance is a concern or if the asset is already scaled
437
483
/// appropriately.
438
484
///
@@ -441,10 +487,10 @@ class AssetMapBitmap extends MapBitmap {
441
487
/// - If both [width] and [height] are non-null, the image will have the
442
488
/// specified dimensions, which might distort the original aspect ratio,
443
489
/// similar to [BoxFit.fill] .
444
- /// - If only one of ` width` and ` height` is non-null, then the output image
490
+ /// - If only one of [ width] and [ height] is non-null, then the output image
445
491
/// will be scaled to the associated width or height, and the other dimension
446
492
/// will take whatever value is needed to maintain the image's original aspect
447
- /// ratio. These cases are simnilar to [BoxFit.fitWidth] and
493
+ /// ratio. These cases are similar to [BoxFit.fitWidth] and
448
494
/// [BoxFit.fitHeight] , respectively.
449
495
///
450
496
/// If [width] or [height] is provided, [imagePixelRatio] value is ignored.
@@ -495,10 +541,10 @@ class AssetMapBitmap extends MapBitmap {
495
541
}) : assert (assetName.isNotEmpty, 'The asset name must not be empty.' ),
496
542
assert (imagePixelRatio > 0.0 ,
497
543
'The imagePixelRatio must be greater than 0.' ),
498
- assert (bitmapScaling != MapBitmapScaling .noScaling || width == null ,
499
- 'If bitmapScaling is set to MapBitmapScaling.noScaling , width parameter cannot be used.' ),
500
- assert (bitmapScaling != MapBitmapScaling .noScaling || height == null ,
501
- 'If bitmapScaling is set to MapBitmapScaling.noScaling , height parameter cannot be used.' ),
544
+ assert (bitmapScaling != MapBitmapScaling .none || width == null ,
545
+ 'If bitmapScaling is set to MapBitmapScaling.none , width parameter cannot be used.' ),
546
+ assert (bitmapScaling != MapBitmapScaling .none || height == null ,
547
+ 'If bitmapScaling is set to MapBitmapScaling.none , height parameter cannot be used.' ),
502
548
super ._();
503
549
504
550
/// The type of the [BitmapDescriptor] object, used for the
@@ -524,17 +570,17 @@ class AssetMapBitmap extends MapBitmap {
524
570
/// - If both [width] and [height] are non-null, the image will have the
525
571
/// specified dimensions, which might distort the original aspect ratio,
526
572
/// similar to [BoxFit.fill] .
527
- /// - If only one of ` width` and ` height` is non-null, then the output image
573
+ /// - If only one of [ width] and [ height] is non-null, then the output image
528
574
/// will be scaled to the associated width or height, and the other
529
575
/// dimension will take whatever value is needed to maintain the image's
530
- /// original aspect ratio. These cases are simnilar to [BoxFit.fitWidth] and
576
+ /// original aspect ratio. These cases are similar to [BoxFit.fitWidth] and
531
577
/// [BoxFit.fitHeight] , respectively.
532
578
///
533
579
/// [bitmapScaling] controls the scaling behavior:
534
580
/// - [MapBitmapScaling.auto] automatically upscales and downscales the image
535
581
/// to match the device's pixel ratio or the specified dimensions,
536
582
/// maintaining consistency across devices.
537
- /// - [MapBitmapScaling.noScaling ] disables automatic scaling, which is
583
+ /// - [MapBitmapScaling.none ] disables automatic scaling, which is
538
584
/// useful when performance is a concern or if the asset is already scaled
539
585
/// appropriately.
540
586
///
@@ -632,7 +678,7 @@ class AssetMapBitmap extends MapBitmap {
632
678
/// - [MapBitmapScaling.auto] automatically upscales and downscales the image
633
679
/// to match the device's pixel ratio or the specified dimensions,
634
680
/// maintaining consistency across devices.
635
- /// - [MapBitmapScaling.noScaling ] disables automatic scaling, which is
681
+ /// - [MapBitmapScaling.none ] disables automatic scaling, which is
636
682
/// useful when performance is a concern or if the asset is already scaled
637
683
/// appropriately.
638
684
///
@@ -647,10 +693,10 @@ class AssetMapBitmap extends MapBitmap {
647
693
/// - If both [width] and [height] are non-null, the image will have the
648
694
/// specified dimensions, which might distort the original aspect ratio,
649
695
/// similar to [BoxFit.fill] .
650
- /// - If only one of ` width` and ` height` is non-null, then the output image
696
+ /// - If only one of [ width] and [ height] is non-null, then the output image
651
697
/// will be scaled to the associated width or height, and the other
652
698
/// dimension will take whatever value is needed to maintain the image's
653
- /// original aspect ratio. These cases are simnilar to [BoxFit.fitWidth] and
699
+ /// original aspect ratio. These cases are similar to [BoxFit.fitWidth] and
654
700
/// [BoxFit.fitHeight] , respectively.
655
701
///
656
702
/// The following example demonstrates how to create an [BytesMapBitmap] from
@@ -701,7 +747,7 @@ class BytesMapBitmap extends MapBitmap {
701
747
/// - [MapBitmapScaling.auto] automatically upscales and downscales the image
702
748
/// to match the device's pixel ratio or the specified dimensions,
703
749
/// maintaining consistency across devices.
704
- /// - [MapBitmapScaling.noScaling ] disables automatic scaling, which is
750
+ /// - [MapBitmapScaling.none ] disables automatic scaling, which is
705
751
/// useful when performance is a concern or if the asset is already scaled
706
752
/// appropriately.
707
753
///
@@ -716,10 +762,10 @@ class BytesMapBitmap extends MapBitmap {
716
762
/// - If both [width] and [height] are non-null, the image will have the
717
763
/// specified dimensions, which might distort the original aspect ratio,
718
764
/// similar to [BoxFit.fill] .
719
- /// - If only one of ` width` and ` height` is non-null, then the output image
765
+ /// - If only one of [ width] and [ height] is non-null, then the output image
720
766
/// will be scaled to the associated width or height, and the other
721
767
/// dimension will take whatever value is needed to maintain the image's
722
- /// original aspect ratio. These cases are simnilar to [BoxFit.fitWidth] and
768
+ /// original aspect ratio. These cases are similar to [BoxFit.fitWidth] and
723
769
/// [BoxFit.fitHeight] , respectively.
724
770
///
725
771
/// Throws an [AssertionError] if [byteData] is empty or if incompatible
@@ -769,13 +815,12 @@ class BytesMapBitmap extends MapBitmap {
769
815
}) : assert (byteData.isNotEmpty,
770
816
'Cannot create BitmapDescriptor with empty byteData.' ),
771
817
assert (
772
- bitmapScaling != MapBitmapScaling .noScaling ||
773
- imagePixelRatio == null ,
774
- 'If bitmapScaling is set to MapBitmapScaling.noScaling, imagePixelRatio parameter cannot be used.' ),
775
- assert (bitmapScaling != MapBitmapScaling .noScaling || width == null ,
776
- 'If bitmapScaling is set to MapBitmapScaling.noScaling, width parameter cannot be used.' ),
777
- assert (bitmapScaling != MapBitmapScaling .noScaling || height == null ,
778
- 'If bitmapScaling is set to MapBitmapScaling.noScaling, height parameter cannot be used.' ),
818
+ bitmapScaling != MapBitmapScaling .none || imagePixelRatio == null ,
819
+ 'If bitmapScaling is set to MapBitmapScaling.none, imagePixelRatio parameter cannot be used.' ),
820
+ assert (bitmapScaling != MapBitmapScaling .none || width == null ,
821
+ 'If bitmapScaling is set to MapBitmapScaling.none, width parameter cannot be used.' ),
822
+ assert (bitmapScaling != MapBitmapScaling .none || height == null ,
823
+ 'If bitmapScaling is set to MapBitmapScaling.none, height parameter cannot be used.' ),
779
824
super ._(imagePixelRatio: imagePixelRatio ?? _naturalPixelRatio);
780
825
781
826
/// The type of the MapBitmap object, used for the JSON serialization.
0 commit comments