From 6c3df4820ab9e44d37a068d17aba328086c62cd2 Mon Sep 17 00:00:00 2001 From: "Afanasov S." Date: Mon, 20 Oct 2025 15:18:54 +0300 Subject: [PATCH] Update responsive_breakpoints.dart. Read window size once --- lib/src/responsive_breakpoints.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/responsive_breakpoints.dart b/lib/src/responsive_breakpoints.dart index 1b0d97a..7e17f98 100644 --- a/lib/src/responsive_breakpoints.dart +++ b/lib/src/responsive_breakpoints.dart @@ -187,11 +187,13 @@ class ResponsiveBreakpointsState extends State /// Set [breakpoints] and [breakpointSegments]. void setBreakpoints() { // Optimization. Only update breakpoints if dimensions have changed. - if ((windowWidth != getWindowWidth()) || - (windowHeight != getWindowHeight()) || + final newWindowWidth = getWindowWidth(); + final newWindowHeight = getWindowHeight(); + if ((windowWidth != newWindowWidth) || + (windowHeight != newWindowHeight) || (windowWidth == 0)) { - windowWidth = getWindowWidth(); - windowHeight = getWindowHeight(); + windowWidth = newWindowWidth; + windowHeight = newWindowHeight; breakpoints.clear(); breakpoints.addAll(getActiveBreakpoints()); breakpoints.sort(ResponsiveUtils.breakpointComparator);