Skip to content

Commit

Permalink
Delay by two frames
Browse files Browse the repository at this point in the history
  • Loading branch information
maxammann committed Jan 25, 2022
1 parent b8363ca commit 3ee33c4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/lib/map/map/screen_parent_resizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ class _ScreenParentResizer extends State<ScreenParentResizer> {

final currentOrientation = MediaQuery.of(context).orientation;
final isOverDrawingSquare = currentOrientation != _lastBuildOrientation;

if (isOverDrawingSquare) {
// Delay setState by 2 frames. If we delay only by one frame, then Flutter is able to optimize this away.
WidgetsBinding.instance!.addPostFrameCallback(
(_) => setState(() {
_lastBuildOrientation = currentOrientation;
}),
(_) => WidgetsBinding.instance!.addPostFrameCallback(
(_) => setState(() {
_lastBuildOrientation = currentOrientation;
}),
),
);
}

Expand Down

0 comments on commit 3ee33c4

Please sign in to comment.