onMetricsChanged property Null safety

VoidCallback? onMetricsChanged

A callback that is invoked whenever the devicePixelRatio, physicalSize, padding, viewInsets, PlatformDispatcher.views, or systemGestureInsets values change.

Accessing this value returns the value contained in the PlatformDispatcher singleton, so instead of getting it from here, you should consider getting it from WidgetsBinding.instance.platformDispatcher instead (or, when WidgetsBinding isn't available, from PlatformDispatcher.instance). The reason this value forwards to the PlatformDispatcher is to provide convenience for applications that only use a single main window.

See PlatformDispatcher.onMetricsChanged for more information.


VoidCallback? get onMetricsChanged => platformDispatcher.onMetricsChanged;
void onMetricsChanged=(VoidCallback? callback)


set onMetricsChanged(VoidCallback? callback) {
  platformDispatcher.onMetricsChanged = callback;