Since I found the solution hidden of my problem in the comments, I am putting it here in a more prominent place:
Problem: I received the above error after awaiting some function within a Dart .fold
method.
_failureOrProperty.fold(
(failure) async => emit(state.copyWith(
status: () => DataTransStatus.failure,
(data) async {
final List<int>? taskTypeCnts = await getTasksCount(_calledId!);
// final List<int>? taskTypeCnts=[1,1];
emit(state.copyWith(
status: () => DataTransStatus.success,
noOfMandatory: () => taskTypeCnts?[0],
noOfOptional: () => taskTypeCnts?[1]
));
}
Using the line in the comment, everything works fine, awaiting getTasksCount()
does not.
The simple solution is amending the first line with
await