diff --git a/lib/services/field_images.dart b/lib/services/field_images.dart index 8e0efe5a..b14c3582 100644 --- a/lib/services/field_images.dart +++ b/lib/services/field_images.dart @@ -106,9 +106,9 @@ class Field { .addListener(ImageStreamListener((image, synchronousCall) { fieldImageWidth = image.image.width; fieldImageHeight = image.image.height; - })); - fieldImageLoaded = true; + fieldImageLoaded = true; + })); } void dispose() { diff --git a/lib/widgets/draggable_containers/draggable_nt_widget_container.dart b/lib/widgets/draggable_containers/draggable_nt_widget_container.dart index c64b769e..f253cec1 100644 --- a/lib/widgets/draggable_containers/draggable_nt_widget_container.dart +++ b/lib/widgets/draggable_containers/draggable_nt_widget_container.dart @@ -188,7 +188,9 @@ class DraggableNTWidgetContainer extends DraggableWidgetContainer { ], ); }, - ); + ).then((_) { + child.refresh(); + }); } Widget getWidgetTypeProperties(StateSetter setState) { diff --git a/lib/widgets/nt_widgets/multi-topic/field_widget.dart b/lib/widgets/nt_widgets/multi-topic/field_widget.dart index d0c44b19..e7391a0d 100644 --- a/lib/widgets/nt_widgets/multi-topic/field_widget.dart +++ b/lib/widgets/nt_widgets/multi-topic/field_widget.dart @@ -133,11 +133,12 @@ class FieldWidget extends NTWidget { } fieldGame = value; - field.dispose(); - field = newField; + widgetSize = null; + rendered = false; + refresh(); }, choices: FieldImages.fields.map((e) => e.game).toList(), @@ -363,6 +364,7 @@ class FieldWidget extends NTWidget { showTrajectories, robotWidthMeters, robotLengthMeters, + otherObjectTopics, fieldGame, ]); @@ -399,9 +401,6 @@ class FieldWidget extends NTWidget { Widget build(BuildContext context) { notifier = context.watch(); - widgetSize = null; - rendered = false; - return StreamBuilder( stream: multiTopicPeriodicStream, builder: (context, snapshot) { @@ -448,7 +447,8 @@ class FieldWidget extends NTWidget { size.width > 100.0 && scaleReduction != 0.0 && robotPosition != null && - fieldCenter != const Offset(0.0, 0.0)) { + fieldCenter != const Offset(0.0, 0.0) && + field.fieldImageLoaded) { rendered = true; }