format method
Formats a number based on the given locale.
The method takes a number and a locale string, and formats the number
according to the locale's decimal pattern.
class to format the number in a way that is appropriate for the specified locale.
Example:
1234567.89.format('en_US');
Output: '1,234,567.89'
Example with a different locale:
1234567.89.format('de_DE');
Output: '1.234.567,89'
number The number to be formatted.
locale The locale to use for formatting.
Returns a string representing the formatted number.
Implementation
String format([String? locale]) {
return Number.format(this ?? 0, locale);
}