Closed
Description
Steps to reproduce
run main -> watch log for prints.
Expected results
A sorted list of times.
Actual results
Unhandled exception:
Stack Overflow
#0 DateTime._equivalentSeconds (dart:core-patch/date_patch.dart:403:3)
#1 DateTime._timeZoneOffsetInSeconds (dart:core-patch/date_patch.dart:421:29)
#2 DateTime._toLocalTimeOffset (dart:core-patch/date_patch.dart:479:18)
#3 DateTime._brokenDownDateToValue (dart:core-patch/date_patch.dart:330:33)
#4 DateTime.parse (dart:core/date_time.dart:351:20)
#5 new Dto (package:duty_planer/orders/AvailabilityOrdreSystem.dart:77:20)
#6 new Dto (package:duty_planer/orders/AvailabilityOrdreSystem.dart:74:15)
#7 new Dto (package:duty_planer/orders/AvailabilityOrdreSystem.dart:74:15)
Code sample
Code sample
void main() {
int lalal =
DateTime.parse("1985-07-20 20:18:04.111111").microsecondsSinceEpoch;
print(lalal);
Dto().currentOrderList().forEach((element) {
print(element);
});
print("object2");
Dto().currentOrderList().sort((a, b) => a.compareTo(b));
Dto().currentOrderList().forEach((element) {
print(element);
});
}
class Dto implements Comparable<Dto> {
double orderID = 1;
int orderDate = 1;
String name = '';
String address = '';
String postalCode = '';
String city = '';
String phone = '';
String email = '';
String currierID = '';
String currierName = '';
String currierPhone = '';
Dto({
this.orderID = 1,
this.orderDate = 1,
this.name = '',
this.address = '',
this.postalCode = '',
this.city = '',
this.phone = '',
this.email = '',
this.currierID = '',
this.currierName = '',
this.currierPhone = '',
});
@override
int compareTo(other) {
if (orderDate < (other.orderDate)) {
return -1;
}
if (orderDate > other.orderDate) {
return 1;
}
// age == other.age
return 0;
}
List<Dto> currentOrderList() {
return List<Dto>.from([
ordre,
ordre2,
ordre3,
ordre4,
ordre5,
ordre6,
ordre7,
ordre8,
]);
}
Dto ordre = Dto(
orderID: 1,
orderDate:
DateTime.parse("2012-02-27 13:27:00").microsecondsSinceEpoch.toInt(),
name: "bob",
address: "1234",
postalCode: "1234",
city: "city",
phone: "1234",
email: " email",
currierID: "1234",
currierName: "name",
currierPhone: "1234");
Dto ordre2 = Dto(
orderID: 2,
orderDate:
DateTime.parse("1985-07-20 20:18:04").microsecondsSinceEpoch.toInt(),
name: "bob2",
address: "1234",
postalCode: "1234",
city: "city",
phone: "1234",
email: " email",
currierID: "1234",
currierName: "name",
currierPhone: "1234");
Dto ordre3 = Dto(
orderID: 2,
orderDate:
DateTime.parse("1986-07-20 20:18:04").microsecondsSinceEpoch.toInt(),
name: "bob3",
address: "1234",
postalCode: "1234",
city: "city",
phone: "1234",
email: " email",
currierID: "1234",
currierName: "name",
currierPhone: "1234");
Dto ordre4 = Dto(
orderID: 2,
orderDate:
DateTime.parse("1987-07-20 20:18:04").microsecondsSinceEpoch.toInt(),
name: "bob4",
address: "1234",
postalCode: "1234",
city: "city",
phone: "1234",
email: " email",
currierID: "1234",
currierName: "name",
currierPhone: "1234");
Dto ordre5 = Dto(
orderID: 2,
orderDate:
DateTime.parse("1988-07-20 20:18:04").microsecondsSinceEpoch.toInt(),
name: "bob5",
address: "1234",
postalCode: "1234",
city: "city",
phone: "1234",
email: " email",
currierID: "1234",
currierName: "name",
currierPhone: "1234");
Dto ordre6 = Dto(
orderID: 2,
orderDate:
DateTime.parse("1989-07-20 20:18:04").microsecondsSinceEpoch.toInt(),
name: "bob6",
address: "1234",
postalCode: "1234",
city: "city",
phone: "1234",
email: " email",
currierID: "1234",
currierName: "name",
currierPhone: "1234");
Dto ordre7 = Dto(
orderID: 2,
orderDate:
DateTime.parse("1990-07-20 20:18:04").microsecondsSinceEpoch.toInt(),
name: "bob7",
address: "1234",
postalCode: "1234",
city: "city",
phone: "1234",
email: " email",
currierID: "1234",
currierName: "name",
currierPhone: "1234");
Dto ordre8 = Dto(
orderID: 2,
orderDate:
DateTime.parse("1991-07-20 20:18:04").microsecondsSinceEpoch.toInt(),
name: "bob8",
address: "1234",
postalCode: "1234",
city: "city",
phone: "1234",
email: " email",
currierID: "1234",
currierName: "name",
currierPhone: "1234");
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-DK) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.4) [✓] Chrome - develop for the web [✓] Android Studio (version 2024.1) [✓] VS Code (version 1.87.2) [✓] Connected device (5 available) [✓] Network resources
Unhandled exception:
Stack Overflow
#0 DateTime._equivalentSeconds (dart:core-patch/date_patch.dart:403:3)
#1 DateTime._timeZoneOffsetInSeconds (dart:core-patch/date_patch.dart:421:29)
#2 DateTime._toLocalTimeOffset (dart:core-patch/date_patch.dart:479:18)
#3 DateTime._brokenDownDateToValue (dart:core-patch/date_patch.dart:330:33)
#4 DateTime.parse (dart:core/date_time.dart:351:20)
#5 new Dto (package:duty_planer/orders/AvailabilityOrdreSystem.dart:77:20)
#6 new Dto (package:duty_planer/orders/AvailabilityOrdreSystem.dart:74:15)
#7 new Dto (package:duty_planer/orders/AvailabilityOrdreSystem.dart:74:15)