diff --git a/lib/widgets/pop_scope.dart b/lib/widgets/pop_scope.dart index 380100b78..decbfc147 100644 --- a/lib/widgets/pop_scope.dart +++ b/lib/widgets/pop_scope.dart @@ -62,10 +62,8 @@ class _SystemBackBlockState extends State { @override void dispose() { + globalState.appController.unBackBlock(); super.dispose(); - WidgetsBinding.instance.addPostFrameCallback((_) { - globalState.appController.unBackBlock(); - }); } @override diff --git a/lib/widgets/scaffold.dart b/lib/widgets/scaffold.dart index a10f781c7..bae8662ed 100644 --- a/lib/widgets/scaffold.dart +++ b/lib/widgets/scaffold.dart @@ -238,19 +238,22 @@ class CommonScaffoldState extends State { Widget _buildAppBarWrap(Widget child) { final appBar = _isSearch ? _buildSearchingAppBarTheme(child) : child; if (_isEdit || _isSearch) { - return SystemBackBlock( - child: CommonPopScope( - onPop: (context) { - if (_isEdit || _isSearch) { - handleExitSearching(); - _appBarState.value.editState?.onExit(); - return false; - } - return true; - }, - child: appBar, - ), + final wrappedAppBar = CommonPopScope( + onPop: (context) { + if (_isEdit || _isSearch) { + handleExitSearching(); + _appBarState.value.editState?.onExit(); + return false; + } + return true; + }, + child: appBar, ); + // Only block system back for edit mode, not search mode + if (_isEdit) { + return SystemBackBlock(child: wrappedAppBar); + } + return wrappedAppBar; } return appBar; }