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: reduce rebuild when end dragging
appflowy4b7713d7b806
diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dartindex bd2f39e926..6f35ae4195 100644--- a/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart+++ b/frontend/app_flowy/packages/appflowy_board/lib/src/utils/log.dart@@ -26,7 +26,7 @@ class Log {static void trace(String? message) {if (enableLog) {- // debugPrint('❗️[Trace] - ${DateTime.now().second}=> $message');+ debugPrint('❗️[Trace] - ${DateTime.now().second}=> $message');}}}diff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dartindex ee1b501e8f..2065d88ba2 100644--- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart+++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/board_column/board_column.dart@@ -112,7 +112,7 @@ class AFBoardColumnWidget extends StatefulWidget {this.cornerRadius = 0.0,this.backgroundColor = Colors.transparent,}) : globalKey = GlobalObjectKey(dataSource.columnData.id),- config = const ReorderFlexConfig(),+ config = const ReorderFlexConfig(setStateWhenEndDrag: false),super(key: key);@overridediff --git a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dartindex 90556440b4..bff76cfe52 100644--- a/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart+++ b/frontend/app_flowy/packages/appflowy_board/lib/src/widgets/reorder_flex/reorder_flex.dart@@ -46,12 +46,20 @@ class ReorderFlexConfig {// How long an animation to scroll to an off-screen elementfinal Duration scrollAnimationDuration = const Duration(milliseconds: 300);+ /// Determines if setSatte method needs to be called when the drag is complete.+ /// Default value is [true].+ ///+ /// If the [ReorderFlex] will be rebuild after the [ReorderFlex]'s children+ /// were changed, then the [setStateWhenEndDrag] should set to [false].+ final bool setStateWhenEndDrag;+final bool useMoveAnimation;final bool useMovePlaceholder;const ReorderFlexConfig({this.useMoveAnimation = true,+ this.setStateWhenEndDrag = true,}) : useMovePlaceholder = !useMoveAnimation;}@@ -370,11 +378,11 @@ class ReorderFlexState extends State<ReorderFlex>},onDragEnded: (dragTargetData) {if (!mounted) return;-Log.debug("[DragTarget]: Column:[${widget.dataSource.identifier}] end dragging");_notifier.updateDragTargetIndex(-1);- setState(() {++ onDragEnded() {if (dragTargetData.reorderFlexId == widget.reorderFlexId) {_onReordered(dragState.dragStartIndex,@@ -383,7 +391,13 @@ class ReorderFlexState extends State<ReorderFlex>}dragState.endDragging();widget.onDragEnded?.call();- });+ }++ if (widget.config.setStateWhenEndDrag) {+ setState(() => onDragEnded());+ } else {+ onDragEnded();+ }},onWillAccept: (FlexDragTargetData dragTargetData) {// Do not receive any events if the Insert item is animating.diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lockindex cdfd764668..8466696ec9 100644--- a/frontend/app_flowy/pubspec.lock+++ b/frontend/app_flowy/pubspec.lock@@ -28,14 +28,14 @@ packages:path: "packages/appflowy_board"relative: truesource: path- version: "0.0.5"+ version: "0.0.6"appflowy_editor:dependency: "direct main"description:path: "packages/appflowy_editor"relative: truesource: path- version: "0.0.2"+ version: "0.0.3"args:dependency: transitivedescription: