touchEvents property Null safety

Feature touchEvents

Whether the browser supports TouchEvents.

Related: msTouchEvents

As of Dart 2.5.0, TouchEvent.supported is always true on Chrome 70+, even on non-touch devices.

This feature checks whether maxTouchPoints is greater than 0 (if it exists, falling back to TouchEvent.supported), which is the recommended way to check for touch screens.



static final Feature touchEvents = Feature(
    window.navigator.maxTouchPoints != null
        ? window.navigator.maxTouchPoints! > 0
        : TouchEvent.supported);