doc_bloc.dart 859 B

123456789101112131415161718192021222324252627282930313233343536
  1. import 'package:app_flowy/workspace/domain/i_doc.dart';
  2. import 'package:freezed_annotation/freezed_annotation.dart';
  3. import 'package:flutter_bloc/flutter_bloc.dart';
  4. part 'doc_bloc.freezed.dart';
  5. class DocBloc extends Bloc<DocEvent, DocState> {
  6. final IDoc iDocImpl;
  7. DocBloc(this.iDocImpl) : super(DocState.initial());
  8. @override
  9. Stream<DocState> mapEventToState(DocEvent event) async* {
  10. yield* event.map(
  11. initial: (e) async* {},
  12. close: (Close value) async* {},
  13. );
  14. }
  15. }
  16. @freezed
  17. abstract class DocEvent with _$DocEvent {
  18. const factory DocEvent.initial() = Initial;
  19. const factory DocEvent.close() = Close;
  20. }
  21. @freezed
  22. abstract class DocState implements _$DocState {
  23. const factory DocState({
  24. required bool isSaving,
  25. }) = _DocState;
  26. factory DocState.initial() => const DocState(
  27. isSaving: false,
  28. );
  29. }