Skip to content
ComPDF
Guides

Custom Toolbar Menu

Since ComPDF Flutter SDK 2.6.0, the SDK supports custom top toolbar menu items and provides corresponding click event callback mechanisms to respond to user interaction with custom toolbar buttons.

For information on how to configure and add custom toolbar menu items, please refer to Main Toolbar.

Listen to Custom Toolbar Menu Item Click Events

When creating CPDFReaderWidget, you can set the onCustomToolbarItemTappedCallback callback to listen to custom toolbar menu item click events. For example:

dart
CPDFReaderWidget(
  document: documentPath,
  configuration: configuration,
  onCreated: (controller) {},
  onCustomToolbarItemTappedCallback: (String identifier) {
    debugPrint('Custom toolbar menu item tapped: $identifier');
    // Handle custom toolbar menu item click logic here
  },
);

Note: Only callbacks for custom toolbar menu items are triggered. Clicks on ComPDF's built-in toolbar menu items (such as search, zoom, etc.) will not trigger this callback. }