Skip to content

Commit

Permalink
extracted resize viewport into own method
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-SD committed Nov 25, 2024
1 parent f156d50 commit d465ac6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/src/components/card/base_card_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,22 @@ class _BaseCardComponentState extends State<BaseCardComponent> {

void _onComponentCommunication(event) {
if (event.type case ComponentCommunicationType.resize) {
final newViewportHeight = event.data as int;
if (newViewportHeight == previousViewportHeight) {
return;
} else {
setState(() {
previousViewportHeight = viewportHeight;
viewportHeight = newViewportHeight;
});
}
_resizeViewport(event);
} else if (event.type case ComponentCommunicationType.result) {
widget.onResult(event);
} else {
widget.handleComponentCommunication(event);
}
}

void _resizeViewport(event) {
final newViewportHeight = event.data is int ? event.data : null;
if (newViewportHeight != previousViewportHeight &&
newViewportHeight != null) {
setState(() {
previousViewportHeight = viewportHeight;
viewportHeight = newViewportHeight;
});
}
}
}

0 comments on commit d465ac6

Please sign in to comment.