tryFormat method

String? tryFormat([
  1. num? maybeValue,
  2. bool isRtl = false
])

If value is not null - formats the value as a string with the currency symbol. Otherwise returns null.

When isRtl is true, the unit position is flipped to ensure correct display in right-to-left locales.

Implementation

// This is limitation of Dart language + breaking change.
// ignore: avoid_positional_boolean_parameters, prefer-named-boolean-parameters
String? tryFormat([num? maybeValue, bool isRtl = false]) =>
    maybeValue == null ? null : format(maybeValue, isRtl: isRtl);