Open
Description
I am using freezed for state class in bloc.
part 'example_state.freezed.dart';
@freezed
class ExampleState with _$ExampleState {
const ExampleState._();
const factory ExampleState({
@Default(ExampleStateBuildStatus.loading) ExampleStateBuildStatus buildStatus,
ExampleStateListenStatus? listenStatus,
}) = _ExampleState;
}
enum ExampleStateBuildStatus {
loading,
loadSuccess,
}
enum ExampleStateListenStatus {
error,
}
And every time I emit new state I need to pass null for listenStatus so listener on UI dont trigger every time or I need to override listenWhen to handle it.
emit(state.copyWith(listenStatus: null))
Can you implemented something like this so when I dont pass nothing it will get CopyWithDefault value:
part 'example_state.freezed.dart';
@freezed
class ExampleState with _$ExampleState {
const ExampleState._();
const factory ExampleState({
@Default(ExampleStateBuildStatus.loading) ExampleStateBuildStatus buildStatus,
@CopyWithDefault(null) ExampleStateListenStatus? listenStatus,
}) = _ExampleState;
}
enum ExampleStateBuildStatus {
loading,
loadSuccess,
}
enum ExampleStateListenStatus {
error,
}