convertToInt function

int convertToInt(
  1. dynamic value
)

Implementation

int convertToInt(dynamic value) {
 if (value is double) {
   // Check if the double is either 0.0 or 1.0, and convert to int
   if (value == 0.0 || value == 1.0) {
     return value.toInt();
   } else {
     throw ArgumentError('Only values 0.0 and 1.0 are allowed');
   }
 } else {
   throw ArgumentError('Input value is not a double');
 }
  }