Closed WanderingFire2001 closed 4 years ago
A consequence of generating List get props => null; is that (with the current Equatable package: equatable 1.0.1), calling hashCode on a generated @object throws NoSuchMethodError.
List get props => null;
To reproduce:
import 'package:super_enum/super_enum.dart'; part "my_state.g.dart"; @superEnum enum _MyState { @object Success, @object Error, }
... // any running code var success = MyState.success(); success.hashCode;
**BOOM! NoSuchMethodError: The method 'fold' was called on null. Receiver: null Tried calling: fold(0, Closure: (int, dynamic) => i**
I got bit pretty hard by this tonight, in test code checking emitsInOrder on a StreamController, but hashCode is called in plenty of situations.
The bug arises because the generator produces
Instead the generator needs to produce:
List get props => const [];
I see you have an outstanding pull request on an unrelated issue that silently fixes this: https://github.com/xsahil03x/super_enum/pull/23
(small nit: that fix assigns props [] and not const []).
[]
const []
Not knowing the timeline for that PR, I wanted to raise this as a separate (and urgent) issue.
@WanderingFire2001 thanks for mentioning, fixed in #23
A consequence of generating
List get props => null;
is that (with the current Equatable package: equatable 1.0.1), calling hashCode on a generated @object throws NoSuchMethodError.To reproduce:
**BOOM! NoSuchMethodError: The method 'fold' was called on null. Receiver: null Tried calling: fold(0, Closure: (int, dynamic) => i**
I got bit pretty hard by this tonight, in test code checking emitsInOrder on a StreamController, but hashCode is called in plenty of situations.
The bug arises because the generator produces
List get props => null;
Instead the generator needs to produce:
List get props => const [];
I see you have an outstanding pull request on an unrelated issue that silently fixes this: https://github.com/xsahil03x/super_enum/pull/23
(small nit: that fix assigns props
[]
and notconst []
).Not knowing the timeline for that PR, I wanted to raise this as a separate (and urgent) issue.