Question: Print type
hkirk opened this issue · 2 comments
I can't seem to wrap my head around how you would print which type MyState would represent. I guess that overriding toString in Inital, Loading, Success or Failure would not give anything.
Overriding toString in MyState makes me change the output from:
emit an event that TaskState:<MyState>
to
emit an event that TaskState:<My custom state message>
Trying to write tests a toy project with your example gives me the following
final expected = [ TaskState.Inital(), TaskState.Failure(error: "MyError"), ]; expectLater(bloc.state, emitsInOrder(expected));
ERROR: Expected: should do the following in order:
• emit an event that TaskState:<MyState>
• emit an event that TaskState:<MyState>
Would be nice to print something like
ERROR: Expected: should do the following in order:
• emit an event that TaskState:<Initial>
• emit an event that TaskState:<Failure>
Hi @hkirk 👋
Thanks for opening an issue!
Unfortunately, I think this is a limitation of sealed_unions
and is not particular to sealed_flutter_bloc
. I would recommend opening an issue on dart_sealed_unions 👍
Thought so, I ended up with something (ugly) as
@override
String toString() {
if (this == TaskState.Initial())
return "Initial";
else if (this == TaskState.Failure())
return "Failure";
}