I am working on a flutter app with banking numbers, and therefore only needs two decimal numbers. Is there a way to round every number automatically in my whole project at once ?
The idea is to not use amount.toStringAsFixed(2)
all the time.
I am working on a flutter app with banking numbers, and therefore only needs two decimal numbers. Is there a way to round every number automatically in my whole project at once ?
The idea is to not use amount.toStringAsFixed(2)
all the time.
2
Answers
Yes you can create one common method for this like below
Access amountFix every where in your whole code like below:
Your common method declare below:
you can access in widget as well like below:
You can make use of dart extension methods.
Define the logic for formatting numbers in an extension.
Use it anywhere in your project.