Skip to content

Commit

Permalink
Set properties to null when none are available (#5986)
Browse files Browse the repository at this point in the history
Fixes behaviour in multiview where widgets, without layout information, weren't behaving well.
  • Loading branch information
CoderDake authored Jul 17, 2023
1 parent 04372e5 commit 0a8cb6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ class BoxLayoutExplorerWidgetState extends LayoutExplorerWidgetState<

@override
Widget build(BuildContext context) {
if (properties == null) return const SizedBox();
if (properties == null) {
final selectedNodeLocal = selectedNode;
return Center(
child: Text(
'${selectedNodeLocal?.description ?? 'Widget'} has no layout properties to display.',
textAlign: TextAlign.center,
overflow: TextOverflow.clip,
),
);
}
return Container(
margin: const EdgeInsets.all(margin),
padding: const EdgeInsets.only(bottom: margin, right: margin),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ abstract class LayoutExplorerWidgetState<W extends LayoutExplorerWidget,
if (shouldFetch) {
_dirty = false;
final newSelection = await fetchLayoutProperties();
if (newSelection != null) {
_setProperties(newSelection);
}
_setProperties(newSelection);
} else {
updateHighlighted(_properties);
}
Expand Down Expand Up @@ -219,7 +217,7 @@ abstract class LayoutExplorerWidgetState<W extends LayoutExplorerWidget,
});
}

void _setProperties(L newProperties) {
void _setProperties(L? newProperties) {
if (!mounted) return;
updateHighlighted(newProperties);
if (_properties == newProperties) {
Expand Down

0 comments on commit 0a8cb6c

Please sign in to comment.