Skip to content

ClientX and ClientY for Pointer Events is wrong type #521

@AndrewLugg

Description

@AndrewLugg

On PointerEvents, if you look at clientX or clientY it returns an int type, but the value is a double. So it will throw an error if you try to do anything with it.

Example to put into Dartpad to show the issue:

import 'dart:js_interop';
import 'package:web/web.dart';

void main() {

  window.document.addEventListener(
    'pointerdown',
    ((Event event) {
      final e = event as PointerEvent;
      print('clientX: ${e.clientX}');
    }).toJS,
  );
}

Example error:

Uncaught Error, error: Error: TypeError: 317.375: type 'double' is not a subtype of type 'int'

This was tested with Dart SDK 3.11.1 with web 1.1.1 and also with DartPad using 3.11.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions