touchEvents property Null safety

Feature touchEvents
final

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.

See:

Implementation

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