You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
762 B
Dart
25 lines
762 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ServiceRequestUtils{
|
|
static int calculateAndAssignWorkingHours({
|
|
required DateTime? startTime,
|
|
required DateTime? endTime,
|
|
required TextEditingController workingHoursController,
|
|
required Function(int) updateModel, // A callback to update the model
|
|
}) {
|
|
print('end date i got is ${endTime}');
|
|
if (startTime != null && endTime != null) {
|
|
|
|
Duration difference = endTime.difference(startTime);
|
|
int hours = difference.inHours;
|
|
|
|
// Update the controller and model
|
|
workingHoursController.text = hours.toString();
|
|
updateModel(hours); // Call the function to update the model
|
|
|
|
return hours;
|
|
} else {
|
|
return -1; // Indicating invalid input
|
|
}
|
|
}
|
|
} |