Skip to content

Commit

Permalink
Add double format extension
Browse files Browse the repository at this point in the history
  • Loading branch information
SepehrFakoori committed Jul 10, 2024
1 parent 69d0451 commit 90aad60
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/util/extensions/double_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extension DoubleFormatting on double {
String doubleDigits() {
if (this < 1 && this.toString().length > 5) {
return this.toStringAsFixed(4);
} else if (this >= 1) {
return this.toStringAsFixed(2);
} else {
return this.toString();
}
}
}

0 comments on commit 90aad60

Please sign in to comment.