Same object, same runtimeType but runtimeType== other.runtimeType is false
itaishalom opened this issue · comments
I encountered a strange issue during my tests.
I'm trying to verify a function call - to my logger:
verify(() => logger.i(WorkflowButtonClicked(value: true))).called(1);
The test runs, and there is a call:
logger.i(new WorkflowButtonClicked(value: true));
WorkflowButtonClicked class extends Equatable, but for some reason, the verify is false.
I checked the code on Equatable class and saw that:
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Equatable &&
runtimeType == other.runtimeType &&
equals(props, other.props);
and the problem is that runtimeType == other.runtimeType is false,
and I can't understand why, because if the String representation of runtimeType is the same.
I tried overriding the runttimeType:
Type get runtimeType {
return WorkflowButtonClicked;
}
but the "==" was still false;
Don't know how to fix this.
Hi @itaishalom 👋
Thanks for opening an issue!
Can you please provide a link to a minimal reproduction sample? Thanks!
Hi, I'm not sure if the issue is related directly to Equatable, I think maybe it's in Flutter itself,
what do you think?
Please check the image attached
Ok I found out what happened, the problem was the import:
bad:
import '../models/logger/log_types/workflow_button_clicked.dart';
good:
import 'package:APP/models/logger/log_types/workflow_button_clicked.dart';