roundTo method

void roundTo(
  1. int decimals
)

Rounds the reactive double to a specified number of decimal places.

Example:

final price = swift(3.14159);
price.roundTo(2); // price.value is now 3.14

Implementation

void roundTo(int decimals) {
  final multiplier = _powerOf10(decimals);
  value = (value * multiplier).round() / multiplier;
}