import 'package:flutter/material.dart'; class ServiceRequestUtils { static double calculateAndAssignWorkingHours({ required DateTime? startTime, required DateTime? endTime, required TextEditingController workingHoursController, required Function(double) updateModel, // A callback to update the model }) { print('start date i got is $startTime'); print('end date i got is $endTime'); if (startTime != null && endTime != null) { Duration difference = endTime.difference(startTime); double hours = difference.inMinutes / 60.0; // Calculate hours as a decimal workingHoursController.text = hours.toStringAsFixed(1); // Format to 1 decimal places updateModel(hours); // Call the function to update the model return hours; } else { return -1; // Indicating invalid input } } }