mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-10 13:09:29 +00:00
feat: Add duration_picker dependency to pubspec.yaml
This commit is contained in:
parent
b98188d7fb
commit
fbd789f989
13 changed files with 558 additions and 49 deletions
31
lib/shared/extensions/time_of_day.dart
Normal file
31
lib/shared/extensions/time_of_day.dart
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
extension ToTimeOfDay on Duration {
|
||||
TimeOfDay toTimeOfDay() {
|
||||
return TimeOfDay(hour: inHours, minute: inMinutes % 60);
|
||||
}
|
||||
}
|
||||
|
||||
extension ToDuration on TimeOfDay {
|
||||
Duration toDuration() {
|
||||
return Duration(hours: hour, minutes: minute);
|
||||
}
|
||||
}
|
||||
|
||||
extension TimeOfDayExtension on TimeOfDay {
|
||||
int compareTo(TimeOfDay other) {
|
||||
if (hour < other.hour) return -1;
|
||||
if (hour > other.hour) return 1;
|
||||
if (minute < other.minute) return -1;
|
||||
if (minute > other.minute) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool operator <(TimeOfDay other) => compareTo(other) < 0;
|
||||
bool operator >(TimeOfDay other) => compareTo(other) > 0;
|
||||
bool operator <=(TimeOfDay other) => compareTo(other) <= 0;
|
||||
bool operator >=(TimeOfDay other) => compareTo(other) >= 0;
|
||||
|
||||
bool isBefore(TimeOfDay other) => this < other;
|
||||
bool isAfter(TimeOfDay other) => this > other;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue