Navaron Bracke

update the result point js interop definition

  1 +import 'dart:js_interop';
  2 +
  3 +/// The JS static interop class for the Result class in the ZXing library.
  4 +///
  5 +/// See also: https://github.com/zxing-js/library/blob/master/src/core/ResultPoint.ts
  6 +@JS()
  7 +@staticInterop
  8 +abstract class Result {}
  9 +
  10 +extension ResultPointExt on Result {
  11 + external JSFunction getX;
  12 +
  13 + external JSFunction getY;
  14 +
  15 + /// The x coordinate of the point.
  16 + double get x {
  17 + final JSNumber? x = getX.callAsFunction() as JSNumber?;
  18 +
  19 + return x?.toDartDouble ?? 0;
  20 + }
  21 +
  22 + /// The y coordinate of the point.
  23 + double get y {
  24 + final JSNumber? y = getY.callAsFunction() as JSNumber?;
  25 +
  26 + return y?.toDartDouble ?? 0;
  27 + }
  28 +}