The abs() function in Dart returns the absolute value of a number.
The figure below shows the mathematical representation of the abs() function.
num.abs()
numis the number whose absolute value is required
The abs() function does not require a parameter.
The abs() function returns the absolute value of a number.
The following code shows how to use the abs() function in Dart:
import 'dart:convert';void main() {//positive numberprint("The value of (0.5).abs(): ${(0.5).abs()} ");// negative numberprint("The value of (-0.5).abs(): ${(-0.5).abs()} ");//zeroprint("The value of (0).abs(): ${(0).abs()}");}
0.5 using abs().-0.5 using abs().0 using abs().