Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: set notifier to null after dispose
appflowyd71e0de8c326
diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/cell_listener.dart b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/cell_listener.dartindex d1fb0acc0c..314345017e 100644--- a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/cell_listener.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/cell_listener.dart@@ -12,7 +12,7 @@ typedef UpdateFieldNotifiedValue = Either<CellNotificationData, FlowyError>;class CellListener {final String rowId;final String fieldId;- PublishNotifier<UpdateFieldNotifiedValue> updateCellNotifier = PublishNotifier();+ PublishNotifier<UpdateFieldNotifiedValue>? updateCellNotifier = PublishNotifier();GridNotificationListener? _listener;CellListener({required this.rowId, required this.fieldId});@@ -24,8 +24,8 @@ class CellListener {switch (ty) {case GridNotification.DidUpdateCell:result.fold(- (payload) => updateCellNotifier.value = left(CellNotificationData.fromBuffer(payload)),- (error) => updateCellNotifier.value = right(error),+ (payload) => updateCellNotifier?.value = left(CellNotificationData.fromBuffer(payload)),+ (error) => updateCellNotifier?.value = right(error),);break;default:@@ -35,6 +35,7 @@ class CellListener {Future<void> stop() async {await _listener?.stop();- updateCellNotifier.dispose();+ updateCellNotifier?.dispose();+ updateCellNotifier = null;}}diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/checkbox_cell_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/checkbox_cell_bloc.dartindex 0f56b9c53c..2d937b8cd2 100644--- a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/checkbox_cell_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/checkbox_cell_bloc.dart@@ -43,7 +43,7 @@ class CheckboxCellBloc extends Bloc<CheckboxCellEvent, CheckboxCellState> {}void _startListening() {- _listener.updateCellNotifier.addPublishListener((result) {+ _listener.updateCellNotifier?.addPublishListener((result) {result.fold((notificationData) async => await _loadCellData(),(err) => Log.error(err),diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/date_cell_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/date_cell_bloc.dartindex 7dd58bf5ac..b4b6d7e152 100644--- a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/date_cell_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/date_cell_bloc.dart@@ -52,7 +52,7 @@ class DateCellBloc extends Bloc<DateCellEvent, DateCellState> {}void _startListening() {- _cellListener.updateCellNotifier.addPublishListener((result) {+ _cellListener.updateCellNotifier?.addPublishListener((result) {result.fold((notificationData) => _loadCellData(),(err) => Log.error(err),@@ -60,7 +60,7 @@ class DateCellBloc extends Bloc<DateCellEvent, DateCellState> {});_cellListener.start();- _fieldListener.updateFieldNotifier.addPublishListener((result) {+ _fieldListener.updateFieldNotifier?.addPublishListener((result) {result.fold((field) {if (!isClosed) {diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/number_cell_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/number_cell_bloc.dartindex a145305bbe..287d70b701 100644--- a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/number_cell_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/number_cell_bloc.dart@@ -59,7 +59,7 @@ class NumberCellBloc extends Bloc<NumberCellEvent, NumberCellState> {}void _startListening() {- _cellListener.updateCellNotifier.addPublishListener((result) {+ _cellListener.updateCellNotifier?.addPublishListener((result) {result.fold((notificationData) async {await _getCellData();@@ -69,7 +69,7 @@ class NumberCellBloc extends Bloc<NumberCellEvent, NumberCellState> {});_cellListener.start();- _fieldListener.updateFieldNotifier.addPublishListener((result) {+ _fieldListener.updateFieldNotifier?.addPublishListener((result) {result.fold((field) => _getCellData(),(err) => Log.error(err),diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/selection_cell_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/selection_cell_bloc.dartindex b7e472e181..dbca1b5ae3 100644--- a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/selection_cell_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/selection_cell_bloc.dart@@ -64,7 +64,7 @@ class SelectionCellBloc extends Bloc<SelectionCellEvent, SelectionCellState> {}void _startListening() {- _cellListener.updateCellNotifier.addPublishListener((result) {+ _cellListener.updateCellNotifier?.addPublishListener((result) {result.fold((notificationData) => _loadOptions(),(err) => Log.error(err),@@ -72,7 +72,7 @@ class SelectionCellBloc extends Bloc<SelectionCellEvent, SelectionCellState> {});_cellListener.start();- _fieldListener.updateFieldNotifier.addPublishListener((result) {+ _fieldListener.updateFieldNotifier?.addPublishListener((result) {result.fold((field) => _loadOptions(),(err) => Log.error(err),diff --git a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/selection_editor_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/selection_editor_bloc.dartindex 5d2c52dc0e..813b779646 100644--- a/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/selection_editor_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/cell_bloc/selection_editor_bloc.dart@@ -134,7 +134,7 @@ class SelectOptionEditorBloc extends Bloc<SelectOptionEditorEvent, SelectOptionE}void _startListening() {- _cellListener.updateCellNotifier.addPublishListener((result) {+ _cellListener.updateCellNotifier?.addPublishListener((result) {result.fold((notificationData) => _loadOptions(),(err) => Log.error(err),@@ -142,7 +142,7 @@ class SelectOptionEditorBloc extends Bloc<SelectOptionEditorEvent, SelectOptionE});_cellListener.start();- _fieldListener.updateFieldNotifier.addPublishListener((result) {+ _fieldListener.updateFieldNotifier?.addPublishListener((result) {result.fold((field) {if (!isClosed) {diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dartindex 11dd1af530..2c148ae452 100644--- a/frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/field/field_cell_bloc.dart@@ -45,7 +45,7 @@ class FieldCellBloc extends Bloc<FieldCellEvent, FieldCellState> {}void _startListening() {- _fieldListener.updateFieldNotifier.addPublishListener((result) {+ _fieldListener.updateFieldNotifier?.addPublishListener((result) {result.fold((field) {if (!isClosed) {diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/field_listener.dart b/frontend/app_flowy/lib/workspace/application/grid/field/field_listener.dartindex 450d88fe18..b31a9c3ff5 100644--- a/frontend/app_flowy/lib/workspace/application/grid/field/field_listener.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/field/field_listener.dart@@ -11,7 +11,7 @@ typedef UpdateFieldNotifiedValue = Either<Field, FlowyError>;class SingleFieldListener {final String fieldId;- PublishNotifier<UpdateFieldNotifiedValue> updateFieldNotifier = PublishNotifier();+ PublishNotifier<UpdateFieldNotifiedValue>? updateFieldNotifier = PublishNotifier();GridNotificationListener? _listener;SingleFieldListener({required this.fieldId});@@ -30,8 +30,8 @@ class SingleFieldListener {switch (ty) {case GridNotification.DidUpdateField:result.fold(- (payload) => updateFieldNotifier.value = left(Field.fromBuffer(payload)),- (error) => updateFieldNotifier.value = right(error),+ (payload) => updateFieldNotifier?.value = left(Field.fromBuffer(payload)),+ (error) => updateFieldNotifier?.value = right(error),);break;default:@@ -41,6 +41,7 @@ class SingleFieldListener {Future<void> stop() async {await _listener?.stop();- updateFieldNotifier.dispose();+ updateFieldNotifier?.dispose();+ updateFieldNotifier = null;}}diff --git a/frontend/app_flowy/lib/workspace/application/grid/field/grid_listenr.dart b/frontend/app_flowy/lib/workspace/application/grid/field/grid_listenr.dartindex c257fe3c0d..6774205a5e 100644--- a/frontend/app_flowy/lib/workspace/application/grid/field/grid_listenr.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/field/grid_listenr.dart@@ -11,7 +11,7 @@ typedef UpdateFieldNotifiedValue = Either<GridFieldChangeset, FlowyError>;class GridFieldsListener {final String gridId;- PublishNotifier<UpdateFieldNotifiedValue> updateFieldsNotifier = PublishNotifier();+ PublishNotifier<UpdateFieldNotifiedValue>? updateFieldsNotifier = PublishNotifier();GridNotificationListener? _listener;GridFieldsListener({required this.gridId});@@ -26,8 +26,8 @@ class GridFieldsListener {switch (ty) {case GridNotification.DidUpdateGridField:result.fold(- (payload) => updateFieldsNotifier.value = left(GridFieldChangeset.fromBuffer(payload)),- (error) => updateFieldsNotifier.value = right(error),+ (payload) => updateFieldsNotifier?.value = left(GridFieldChangeset.fromBuffer(payload)),+ (error) => updateFieldsNotifier?.value = right(error),);break;default:@@ -37,6 +37,7 @@ class GridFieldsListener {Future<void> stop() async {await _listener?.stop();- updateFieldsNotifier.dispose();+ updateFieldsNotifier?.dispose();+ updateFieldsNotifier = null;}}diff --git a/frontend/app_flowy/lib/workspace/application/grid/grid_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/grid_bloc.dartindex 882b3eb5b4..c37c31ec46 100644--- a/frontend/app_flowy/lib/workspace/application/grid/grid_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/grid_bloc.dart@@ -58,7 +58,7 @@ class GridBloc extends Bloc<GridEvent, GridState> {}void _startListening() {- _fieldListener.updateFieldsNotifier.addPublishListener((result) {+ _fieldListener.updateFieldsNotifier?.addPublishListener((result) {result.fold((changeset) {fieldCache.applyChangeset(changeset);diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dartindex dbbe9b054d..b16d75dc92 100644--- a/frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/row/row_bloc.dart@@ -73,7 +73,7 @@ class RowBloc extends Bloc<RowEvent, RowState> {}Future<void> _startListening() async {- _rowlistener.updateRowNotifier.addPublishListener((result) {+ _rowlistener.updateRowNotifier?.addPublishListener((result) {result.fold((row) => add(RowEvent.didUpdateRow(row)),(err) => Log.error(err),diff --git a/frontend/app_flowy/lib/workspace/application/grid/row/row_listener.dart b/frontend/app_flowy/lib/workspace/application/grid/row/row_listener.dartindex 716d252802..7d947b8482 100644--- a/frontend/app_flowy/lib/workspace/application/grid/row/row_listener.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/row/row_listener.dart@@ -12,7 +12,7 @@ typedef UpdateFieldNotifiedValue = Either<List<Field>, FlowyError>;class RowListener {final String rowId;- PublishNotifier<UpdateRowNotifiedValue> updateRowNotifier = PublishNotifier();+ PublishNotifier<UpdateRowNotifiedValue>? updateRowNotifier = PublishNotifier();GridNotificationListener? _listener;RowListener({required this.rowId});@@ -25,8 +25,8 @@ class RowListener {switch (ty) {case GridNotification.DidUpdateRow:result.fold(- (payload) => updateRowNotifier.value = left(Row.fromBuffer(payload)),- (error) => updateRowNotifier.value = right(error),+ (payload) => updateRowNotifier?.value = left(Row.fromBuffer(payload)),+ (error) => updateRowNotifier?.value = right(error),);break;default:@@ -36,6 +36,7 @@ class RowListener {Future<void> stop() async {await _listener?.stop();- updateRowNotifier.dispose();+ updateRowNotifier?.dispose();+ updateRowNotifier = null;}}diff --git a/frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart b/frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dartindex 0ec31d08b6..634bb1e56d 100644--- a/frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart+++ b/frontend/app_flowy/lib/workspace/application/grid/setting/property_bloc.dart@@ -51,7 +51,7 @@ class GridPropertyBloc extends Bloc<GridPropertyEvent, GridPropertyState> {}void _startListening() {- _fieldListener.updateFieldsNotifier.addPublishListener((result) {+ _fieldListener.updateFieldsNotifier?.addPublishListener((result) {result.fold((changeset) {_fieldCache.applyChangeset(changeset);diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dartindex dcf5702f40..a00b9e6295 100644--- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/header/grid_header.dart@@ -25,6 +25,7 @@ class GridHeaderSliverAdaptor extends StatelessWidget {create: (context) =>getIt<GridHeaderBloc>(param1: gridId, param2: fieldCache)..add(const GridHeaderEvent.initial()),child: BlocBuilder<GridHeaderBloc, GridHeaderState>(+ buildWhen: (previous, current) => previous.fields.length != current.fields.length,builder: (context, state) {return SliverPersistentHeader(delegate: SliverHeaderDelegateImplementation(gridId: gridId, fields: state.fields),@@ -45,7 +46,7 @@ class SliverHeaderDelegateImplementation extends SliverPersistentHeaderDelegate@overrideWidget build(BuildContext context, double shrinkOffset, bool overlapsContent) {- return _GridHeader(gridId: gridId, fields: fields, key: ObjectKey(fields));+ return _GridHeader(gridId: gridId, fields: fields);}@override