Skip to main content

toDart()

toDart(x): any

Converts a JavaScript object to its Dart representation.

Conversion rules (checked in order):

  1. null/undefined -> passed through
  2. dayjs object -> Dart DateTime
  3. Object with toDart() method -> calls x.toDart()
  4. Object with dart property -> returns x.dart
  5. Plain object {} -> Dart Map
  6. JavaScript BigInt -> Dart BigInt
  7. Everything else -> passed through unchanged

Parameters

ParameterTypeDescription
xanyJavaScript object to convert

Returns

any

Dart object handle

See

  • toJs for the reverse operation
  • ./dart-interop.md for full documentation

Source

src/wrappers_impl.ts:122