diff --git a/demo/lib/screen/feature/column_menu_screen.dart b/demo/lib/screen/feature/column_menu_screen.dart index ba46552f4..53027841b 100644 --- a/demo/lib/screen/feature/column_menu_screen.dart +++ b/demo/lib/screen/feature/column_menu_screen.dart @@ -113,3 +113,23 @@ enum _UserColumnMenuItem { moveNext, movePrevious, } + +/// [CustomColumnMenu] override buildMenuItems with returnning empty array to make that pop up menu won't trigger +class CustomColumnMenu implements PlutoColumnMenuDelegate { + @override + List buildMenuItems({ + required PlutoGridStateManager stateManager, + required PlutoColumn column, + }) { + return []; + } + + @override + void onSelected({ + required BuildContext context, + required PlutoGridStateManager stateManager, + required PlutoColumn column, + required bool mounted, + required selected, + }) {} +} diff --git a/lib/src/helper/show_column_menu.dart b/lib/src/helper/show_column_menu.dart index 878eab54c..b59581a96 100644 --- a/lib/src/helper/show_column_menu.dart +++ b/lib/src/helper/show_column_menu.dart @@ -84,18 +84,24 @@ Future? showColumnMenu({ final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox; - return showMenu( - context: context, - color: backgroundColor, - position: RelativeRect.fromLTRB( - position.dx, - position.dy, - position.dx + overlay.size.width, - position.dy + overlay.size.height, - ), - items: items, - useRootNavigator: true, - ); + // Add isNotEmpty checking here so that won't pop up menu + // when can pass in empty array on buildMenuItems on class PlutoColumnMenuDelegate + // refer to ColumnMenuScreen class + if (items.isNotEmpty){ + return showMenu( + context: context, + color: backgroundColor, + position: RelativeRect.fromLTRB( + position.dx, + position.dy, + position.dx + overlay.size.width, + position.dy + overlay.size.height, + ), + items: items, + useRootNavigator: true, + ); + } + } List> _getDefaultColumnMenuItems({