Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the implementation of isEven in int.dart class?

Tags:

dart

If you open int.dart class source code, you'll find isEven is written as:

/** Returns true if and only if this integer is even. */
bool get isEven;

I want to know in which class this method is implemented?

like image 820
iDecode Avatar asked Jan 28 '26 20:01

iDecode


1 Answers

It's implemented in the implementation class which implements the int interface. Which class that is (or if there really is a class) depends on the backend.

The VM has a number of classes implementing int, but all of them get their isEven implementation from the same superclass.

When compiling to JavaScript, integers are represented directly by JavaScript numbers. The compiled code treats those as Dart objects implementing the internal class, and that too implements isEven.

like image 56
lrn Avatar answered Feb 03 '26 05:02

lrn