diff --git a/frontend/appflowy_flutter/lib/plugins/document/document_page.dart b/frontend/appflowy_flutter/lib/plugins/document/document_page.dart index 4e15128788..46ef2ca7f2 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/document_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/document_page.dart @@ -55,6 +55,8 @@ class _DocumentPageState extends State Selection? initialSelection; late final documentBloc = DocumentBloc(documentId: widget.view.id) ..add(const DocumentEvent.initial()); + late final viewBloc = ViewBloc(view: widget.view) + ..add(const ViewEvent.initial()); @override void initState() { @@ -66,6 +68,7 @@ class _DocumentPageState extends State void dispose() { WidgetsBinding.instance.removeObserver(this); documentBloc.close(); + viewBloc.close(); super.dispose(); } @@ -88,14 +91,9 @@ class _DocumentPageState extends State BlocProvider.value(value: documentBloc), BlocProvider.value( value: ViewLockStatusBloc(view: widget.view) - ..add( - ViewLockStatusEvent.initial(), - ), - ), - BlocProvider( - create: (_) => - ViewBloc(view: widget.view)..add(const ViewEvent.initial()), + ..add(ViewLockStatusEvent.initial()), ), + BlocProvider.value(value: viewBloc), ], child: BlocConsumer( listenWhen: (prev, curr) => curr.isLocked != prev.isLocked,