mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
17 lines
466 B
Dart
17 lines
466 B
Dart
import 'package:nc_photos/string_extension.dart';
|
|
|
|
extension DoubleExtension on double {
|
|
/// Same as toStringAsFixed but with trailing zeros truncated
|
|
String toStringAsFixedTruncated(int fractionDigits) {
|
|
String tmp = toStringAsFixed(fractionDigits);
|
|
if (fractionDigits == 0) {
|
|
return tmp;
|
|
}
|
|
tmp = tmp.trimRightAny("0");
|
|
if (tmp.endsWith(".")) {
|
|
return tmp.substring(0, tmp.length - 1);
|
|
} else {
|
|
return tmp;
|
|
}
|
|
}
|
|
}
|