getNumberProperty method

NumberPropertyStream getNumberProperty(
  1. String propertyPath
)

Gets a stream for a number property at the specified propertyPath.

Returns a NumberPropertyStream that provides:

  • .stream - Emits the number when complete
  • .future - Completes with the parsed number value

Example:

final age = await parser.getNumberProperty('user.age').future;
print('Age: $age');

Throws Exception if the property at this path is not a number.

Implementation

NumberPropertyStream getNumberProperty(String propertyPath) {
  if (_propertyControllers[propertyPath] != null &&
      _propertyControllers[propertyPath] is! NumberPropertyStreamController) {
    throw Exception(
      'Property at path $propertyPath is not a NumberPropertyStream',
    );
  }
  final controller = _propertyControllers.putIfAbsent(
    propertyPath,
    () => NumberPropertyStreamController(
      parserController: _controller,
      propertyPath: propertyPath,
    ),
  ) as NumberPropertyStreamController;
  return controller.propertyStream;
}