instance property Null safety
The PlatformDispatcher singleton.
Consider avoiding static references to this singleton though
PlatformDispatcher.instance and instead prefer using a binding for
dependency resolution such as
Static access of this object means that Flutter has few, if any options to fake or mock the given object in tests. Even in cases where Dart offers special language constructs to forcefully shadow such properties, those mechanisms would only be reasonable for tests and they would not be reasonable for a future of Flutter where we legitimately want to select an appropriate implementation at runtime.
The only place that
inappropriate is if access to these APIs is required before the binding is
initialized by invoking
WidgetsFlutterBinding.instance.ensureInitialized(). In that case, it is
necessary (though unfortunate) to use the PlatformDispatcher.instance
static PlatformDispatcher get instance => _instance;