Skip to content

Commit

Permalink
ContextMenuEntry
Browse files Browse the repository at this point in the history
make onTap property optional
  • Loading branch information
chesnoksatan committed Aug 4, 2022
1 parent a41ce4c commit b34967a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/widgets/context_menu/context_menu_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class BaseContextMenuEntry extends PopupMenuEntry<String> {
/// [ContextSubMenuEntry] is a [PopupMenuEntry] that displays a base menu entry.
class ContextMenuEntry extends BaseContextMenuEntry {
/// A tap with a primary button has occurred.
final VoidCallback onTap;
final VoidCallback? onTap;

/// Optional content to display keysequence after the title.
/// Typically a [Text] widget.
Expand All @@ -44,7 +44,7 @@ class ContextMenuEntry extends BaseContextMenuEntry {
const ContextMenuEntry({
required String id,
required Widget title,
required this.onTap,
this.onTap,
Widget? leading,
this.shortcut,
bool enabled = true,
Expand All @@ -71,7 +71,7 @@ class _ContextMenuEntryState extends State<ContextMenuEntry> {
onTap: widget.enabled
? () {
Navigator.pop(context);
widget.onTap.call();
widget.onTap?.call();
}
: null,
child: Container(
Expand Down
10 changes: 5 additions & 5 deletions lib/widgets/entity_context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,35 @@ class EntityContextMenu extends StatelessWidget {
ContextMenuEntry(
id: 'open',
title: const Text("Open"),
onTap: () => onOpen?.call(),
onTap: onOpen,
shortcut: const Text("Return"),
),
ContextMenuEntry(
id: 'open_with',
title: const Text("Open with other application"),
onTap: () => onOpenWith?.call(),
onTap: onOpenWith,
enabled: false,
),
const ContextMenuDivider(),
ContextMenuEntry(
id: 'copy',
leading: const Icon(Icons.file_copy_outlined),
title: const Text("Copy file"),
onTap: () => onCopy?.call(),
onTap: onCopy,
shortcut: const Text("Ctrl+C"),
),
ContextMenuEntry(
id: 'cut',
leading: const Icon(Icons.cut_outlined),
title: const Text("Cut file"),
onTap: () => onCut?.call(),
onTap: onCut,
shortcut: const Text("Ctrl+X"),
),
ContextMenuEntry(
id: 'paste',
leading: const Icon(Icons.paste_outlined),
title: const Text("Paste file"),
onTap: () => onPaste?.call(),
onTap: onPaste,
shortcut: const Text("Ctrl+V"),
)
],
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ class FileCell extends StatelessWidget {
borderRadius: BorderRadius.circular(4),
),
child: InkWell(
onTap: () => onTap?.call(),
onTap: onTap,
onDoubleTap: () {
onTap?.call();
onDoubleTap?.call();
},
onLongPress: () => onLongTap?.call(),
onLongPress: onLongTap,
child: EntityContextMenu(
onOpen: () {
onTap?.call();
Expand Down

0 comments on commit b34967a

Please sign in to comment.