getWindowSize static method

Size getWindowSize()

Gets the current window size synchronously.

Returns Size.zero if window is not available.

Implementation

static Size getWindowSize() {
  final binding = WidgetsFlutterBinding.ensureInitialized();
  final window = binding.platformDispatcher.implicitView;
  if (window == null) return Size.zero;
  return window.physicalSize / window.devicePixelRatio;
}