Hi Guys, Welcome to Proto Coders Point. This article is all about how to round number to decimal places in flutter/dart.

What do mean by round to decimal places

Check out below image

Flutter round number to decimal places will make use of a in-build method, .toStringAsFixed(2) will help us in getting how much fraction Digits we need after the decimal point and the last number will get round up.


var num = 15.12345;
  print(num.toStringAsFixed(3));      /// 

Here in .toStringAsFixed(3), Here 3 defines the parameter, How many decimal number you want after decimal point.


void main(){
 var n = 15.12345;
  print(n.toStringAsFixed(3));  //  15.123
  var x = 4.56;
   print(x.toStringAsFixed(1));  //   4.6
    var x1 = 4.53;
   print(x1.toStringAsFixed(1));   //   4.5
  var y = -1.55;
   print(y.toStringAsFixed(1));    //   -1.6
  var z = 10.5677;
   print(z.toStringAsFixed(3));    //    10.568

 var num = 10.85;
   print(z.toStringAsFixed(0));    //    10

dart convert double to int

Ternary Operator in dart

why does flutter uses dart language

dart decimal grouping, add commas to number

convert set to list, list to sets in dart

what is spy number in dart

Flutter count down timer - YouTube ...
Flutter count down timer - YouTube #Shorts Dart tutorial