@@ -359,12 +359,12 @@ class LayerController {
359359 StreamController (onCancel: () => handle? .remove ());
360360
361361 handle = watch (
362- ( ) => view.zoom,
363- (zoom, _) {
362+ allowInterop (( ) => view.zoom) ,
363+ allowInterop ( (zoom, _) {
364364 if (! controller.isClosed && zoom as double > 0 ) {
365365 controller.add (zoom);
366366 }
367- },
367+ }) ,
368368 );
369369
370370 // Merge all the zoom streams into one
@@ -397,18 +397,16 @@ class LayerController {
397397 StreamController (onCancel: () => handle? .remove ());
398398
399399 handle = watch (
400- () => view.center,
401- (center, _) {
402- if (center != null && ! controller.isClosed) {
403- final centerViewPoint = LatLng (
404- (center as JsPoint ).latitude,
405- center.longitude,
406- );
407- controller.add (centerViewPoint);
400+ allowInterop (() => view.center),
401+ allowInterop ((center, _) {
402+ if (! controller.isClosed && center != null ) {
403+ final point = center as JsPoint ;
404+ controller.add (LatLng (point.latitude, point.longitude));
408405 }
409- },
406+ }) ,
410407 );
411408
409+ // Merge all the center position streams into one
412410 return controller.stream;
413411 }
414412
@@ -455,48 +453,50 @@ class LayerController {
455453 );
456454
457455 handle = watch (
458- () => view.extent,
459- (extent, _) {
460- if (! controller.isClosed) {
461- final List <String > graphicIdsInView = < String > [];
462-
463- // Return all the visible graphic ids in the MapView
464- view.graphics.forEach (
465- allowInterop ((JsGraphic graphic, _, __) {
466- final bool isInView =
467- (extent as JsExtent ? )? .intersects (graphic.geometry.extent) ??
468- false ;
469- if (isInView) {
470- graphicIdsInView.add (graphic.attributes.id);
471- }
472- }),
473- );
456+ allowInterop (() => view.extent),
457+ allowInterop (
458+ (extent, _) {
459+ if (! controller.isClosed) {
460+ final List <String > graphicIdsInView = < String > [];
461+
462+ // Return all the visible graphic ids in the MapView
463+ view.graphics.forEach (
464+ allowInterop ((JsGraphic graphic, _, __) {
465+ final bool isInView = (extent as JsExtent ? )
466+ ? .intersects (graphic.geometry.extent) ??
467+ false ;
468+ if (isInView) {
469+ graphicIdsInView.add (graphic.attributes.id);
470+ }
471+ }),
472+ );
474473
475- // Return all the visible graphic ids in the graphic layers
476- final layers = map.layers;
477- layers? .forEach (
478- allowInterop ((layer, _, __) {
479- if (layer is JsGraphicsLayer ) {
480- layer.graphics? .forEach (
481- allowInterop ((JsGraphic graphic, _, __) {
482- final bool isInView = (extent as JsExtent ? )
483- ? .intersects (graphic.geometry.extent) ??
484- false ;
485- if (isInView) {
486- graphicIdsInView.add (graphic.attributes.id);
487- }
488- }),
489- );
490- }
491- }),
492- );
474+ // Return all the visible graphic ids in the graphic layers
475+ final layers = map.layers;
476+ layers? .forEach (
477+ allowInterop ((layer, _, __) {
478+ if (layer is JsGraphicsLayer ) {
479+ layer.graphics? .forEach (
480+ allowInterop ((JsGraphic graphic, _, __) {
481+ final bool isInView = (extent as JsExtent ? )
482+ ? .intersects (graphic.geometry.extent) ??
483+ false ;
484+ if (isInView) {
485+ graphicIdsInView.add (graphic.attributes.id);
486+ }
487+ }),
488+ );
489+ }
490+ }),
491+ );
493492
494- if (! listEquals (graphicIdsInViewBuffer, graphicIdsInView)) {
495- controller.add (graphicIdsInView);
496- graphicIdsInViewBuffer = graphicIdsInView;
493+ if (! listEquals (graphicIdsInViewBuffer, graphicIdsInView)) {
494+ controller.add (graphicIdsInView);
495+ graphicIdsInViewBuffer = graphicIdsInView;
496+ }
497497 }
498- }
499- } ,
498+ },
499+ ) ,
500500 );
501501 // Merge all the streams into one
502502 return controller.stream;
@@ -509,14 +509,14 @@ class LayerController {
509509 JsView view,
510510 JsEsriMap map,
511511 ) {
512- final extent = view.get ( ' extent' ) as JsExtent ? ;
512+ final extent = view.extent;
513513
514514 // Return all the visible graphic ids in the MapView
515515 final List <String > graphicIdsInView = < String > [];
516516 view.graphics.forEach (
517517 allowInterop ((JsGraphic graphic, _, __) {
518518 final bool isInView =
519- extent? .intersects (graphic.geometry.extent) ?? false ;
519+ extent.intersects (graphic.geometry.extent) ?? false ;
520520 if (isInView) {
521521 graphicIdsInView.add (graphic.attributes.id);
522522 }
@@ -531,7 +531,7 @@ class LayerController {
531531 layer.graphics? .forEach (
532532 allowInterop ((JsGraphic graphic, _, __) {
533533 final bool isInView =
534- extent? .intersects (graphic.geometry.extent) ?? false ;
534+ extent.intersects (graphic.geometry.extent) ?? false ;
535535 if (isInView) {
536536 graphicIdsInView.add (graphic.attributes.id);
537537 }
@@ -566,46 +566,47 @@ class LayerController {
566566 /// Gets the current bounds streams of the active views.
567567 Stream <BoundingBox > _getCurrentBoundsStreams (JsView view) {
568568 streamsRefreshed.add (boundsStreamRefreshedForCurrentView);
569-
570- // In order to stop watching on the extent when the stream is canceled in Dart,
569+ // In order to stop watching on the bounds when the stream is canceled in Dart,
571570 // a handle is assigned to the watch method, and it is removed when the Stream is canceled.
572571 WatchHandle ? handle;
573572 final StreamController <BoundingBox > controller =
574573 StreamController (onCancel: () => handle? .remove ());
575574
576575 handle = watch (
577- () => view.extent,
578- (newValue, _) {
579- if (newValue is JsExtent && ! controller.isClosed) {
580- final centerViewPoint =
581- LatLng (newValue.center.latitude, newValue.center.longitude);
582- final xDistanceFromViewCenter = newValue.width / 2 ;
583- final yDistanceFromViewCenter = newValue.height / 2 ;
584-
585- // Lower left point
586- final latLngMin = BoundingBox .getLatLngFromMapUnits (
587- referencePoint: centerViewPoint,
588- x: - xDistanceFromViewCenter,
589- y: - yDistanceFromViewCenter,
590- );
576+ allowInterop (() => view.extent),
577+ allowInterop (
578+ (newValue, _) {
579+ if (newValue is JsExtent && ! controller.isClosed) {
580+ final centerViewPoint =
581+ LatLng (newValue.center.latitude, newValue.center.longitude);
582+ final xDistanceFromViewCenter = newValue.width / 2 ;
583+ final yDistanceFromViewCenter = newValue.height / 2 ;
584+
585+ // Lower left point
586+ final latLngMin = BoundingBox .getLatLngFromMapUnits (
587+ referencePoint: centerViewPoint,
588+ x: - xDistanceFromViewCenter,
589+ y: - yDistanceFromViewCenter,
590+ );
591591
592- // Top right point
593- final latLngMax = BoundingBox .getLatLngFromMapUnits (
594- referencePoint: centerViewPoint,
595- x: xDistanceFromViewCenter,
596- y: yDistanceFromViewCenter,
597- );
592+ // Top right point
593+ final latLngMax = BoundingBox .getLatLngFromMapUnits (
594+ referencePoint: centerViewPoint,
595+ x: xDistanceFromViewCenter,
596+ y: yDistanceFromViewCenter,
597+ );
598598
599- controller.add (
600- BoundingBox (
601- height: newValue.height,
602- width: newValue.width,
603- lowerLeft: latLngMin,
604- topRight: latLngMax,
605- ),
606- );
607- }
608- },
599+ controller.add (
600+ BoundingBox (
601+ height: newValue.height,
602+ width: newValue.width,
603+ lowerLeft: latLngMin,
604+ topRight: latLngMax,
605+ ),
606+ );
607+ }
608+ },
609+ ),
609610 );
610611
611612 return controller.stream;
0 commit comments