emit was called after an event handler completed normally.
This is usually due to an unawaited future in an event handler.
Please make sure to await all asynchronous operations with event handlers
and use emit.isDone after asynchronous operations before calling emit() to
ensure the event handler has not completed.
BAD
on((event, emit) {
future.whenComplete(() => emit(...));
});
GOOD
on((event, emit) async {
await future.whenComplete(() => emit(...));
});
Unhandled Exception: 'package:bloc/src/emitter.dart': Failed assertion: '!_isCompleted'
emit was called after an event handler completed normally. This is usually due to an unawaited future in an event handler. Please make sure to await all asynchronous operations with event handlers and use emit.isDone after asynchronous operations before calling emit() to ensure the event handler has not completed.
BAD on((event, emit) {
future.whenComplete(() => emit(...));
});
GOOD on((event, emit) async {
await future.whenComplete(() => emit(...));
});