I would expect both tests to return true, as per the documentation for the == operator on TZDateTime:
/// Returns true if [other] is a [TZDateTime] at the same moment and in the
/// same [Location].
/// ...
@override
bool operator ==(Object other) {
return identical(this, other) ||
other is TZDateTime &&
_native.isAtSameMomentAs(other._native) &&
location == other.location;
}
I think this is failing when the TZDateTime is created in a different isolate because Location does not override == so falls back on an identity check, which fails because it comes from a different instance of the location which was created inside the second isolate.
I suggest that Location should implement == and return true if the location names are the same?
Comparing two identical TZDateTimes created in different isolates fails, because
Location
uses identity not equality for==
. For example:Actual results:
I would expect both tests to return true, as per the documentation for the
==
operator onTZDateTime
:I think this is failing when the TZDateTime is created in a different isolate because
Location
does not override==
so falls back on an identity check, which fails because it comes from a different instance of the location which was created inside the second isolate.I suggest that
Location
should implement==
and return true if the location names are the same?Minimal reproducible example
``` import 'dart:isolate'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:timezone/data/latest.dart'; import 'package:timezone/timezone.dart'; void main() { initializeTimeZones(); runApp(const MaterialApp( home: Example(), )); } class Example extends StatefulWidget { const Example(); @override State