Flutter Decimal

Flutter Decimal:

In this tutorial, we are going to learn computation with a decimal number. without losing any number of data/value. it is very useful to perform decimal operations in flutter app. In this tutorial, you are going to perform some basic computations for example, like adding two decimal values.

Creating Decimal in Flutter:

Follow the below procedure to create computing decimal in Flutter app.

Add the dependency package:

adding the dependency package to pubspec.yaml file. use the below code to add dependency package. After adding the dependency package run the get package method to import all the required files to the Flutter Decimal app.

dependencies:
decimal: ^0.3.3

Install the package:

You can install the package from the command line using the below code with Flutter as shown.

$ flutter packages get

Importing the Package:

After Adding the dependency package to the pubspec.yaml file , you can now import the package into the dart code by using the below code. without adding the dependency package to the pubspec.yaml file if you import it will show package not found an error.

import 'package:decimal/decimal.dart';

Complete Example Code For Flutter decimal App:

Copy and Paste below code into your main.dart

import 'package:decimal/decimal.dart';

void main() {
print(Decimal.parse('0.1') + Decimal.parse('0.2'));
}

Congratulations You Have Learned Flutter Decimal Computations….!!!

If It Is Helpful Share It With Your Friends….!!!

Leave a Reply

Categories