flutterdart

How to get fractional part in dart


is there any way to print out the fractional part of a double,

My double number,

4734.602654867

I want only 6026 from it.


Solution

  • You can do that using split().

    Like this:

    var s = 4734.602654867;
    var a = s.toString().split('.')[1]. substring(0,4); // here a = 6026