0

Hello Stack Overflow community,

I'm currently working on a Dart project, and I need to obtain the minimum and maximum values for the int and double data types. I'm aware that Dart doesn't provide specific constants like int.MIN_VALUE or double.MAX_VALUE as some other languages do.

I would appreciate it if someone could guide me on how to retrieve these values correctly in Dart. What is the recommended approach to obtain the maximum and minimum values for int and double?

Thank you in advance for your assistance!

Siavash TS
  • 41
  • 4
  • 1
    Does this answer your question? [Dart List min/max value](https://stackoverflow.com/questions/20490868/dart-list-min-max-value) – Craicerjack Jul 10 '23 at 09:57
  • 1
    https://stackoverflow.com/questions/50429660/is-there-a-constant-for-max-min-int-double-value-in-dart – fsw Jul 10 '23 at 13:22
  • @Craicerjack Thank you, But It's not my answer. I'm talking about data types like `int` or `double` not the `Iterable` types. – Siavash TS Jul 11 '23 at 10:19
  • Do you mean in use throughout your application or how are you comparing these datatypes for there to be a min or a max? – Craicerjack Jul 12 '23 at 08:14

1 Answers1

-1

Minimum & maximum value of list in dart

// Creating a  list
var list = [121, 12, 33, 14, 2, 3, 1.5, -1];

// Sorting the list
list.sort();

// Printing the values
debugPrint("Smallest value in the list : ${list.first}");
debugPrint("Largest value in the list : ${list.last}");

Output:

Smallest value in the list : -1
Largest value in the list : 121
Priyanka patel
  • 156
  • 2
  • 10