Skip to content

Commit

Permalink
Fixed robot not showing after changing field image
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 17, 2023
1 parent 14eda5b commit 6231988
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/services/field_images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ class Field {
.addListener(ImageStreamListener((image, synchronousCall) {
fieldImageWidth = image.image.width;
fieldImageHeight = image.image.height;
}));

fieldImageLoaded = true;
fieldImageLoaded = true;
}));
}

void dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ class DraggableNTWidgetContainer extends DraggableWidgetContainer {
],
);
},
);
).then((_) {
child.refresh();
});
}

Widget getWidgetTypeProperties(StateSetter setState) {
Expand Down
12 changes: 6 additions & 6 deletions lib/widgets/nt_widgets/multi-topic/field_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -363,6 +364,7 @@ class FieldWidget extends NTWidget {
showTrajectories,
robotWidthMeters,
robotLengthMeters,
otherObjectTopics,
fieldGame,
]);

Expand Down Expand Up @@ -399,9 +401,6 @@ class FieldWidget extends NTWidget {
Widget build(BuildContext context) {
notifier = context.watch<NTWidgetNotifier?>();

widgetSize = null;
rendered = false;

return StreamBuilder(
stream: multiTopicPeriodicStream,
builder: (context, snapshot) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 6231988

Please sign in to comment.