buildNativeMenus method
Kept for tests / hosts that want the same menu model as a PlatformMenuBar.
Implementation
List<PlatformMenuItem> buildNativeMenus({
void Function(VoidCallback action)? runGuarded,
}) {
void run(VoidCallback action) {
if (runGuarded != null) {
runGuarded(action);
} else {
action();
}
}
return [
PlatformMenu(
label: 'View',
menus: [
PlatformMenuItem(
label: 'Network',
shortcut: InfospectDesktopShortcuts.networkTab,
onSelected: () => run(selectNetwork),
),
PlatformMenuItem(
label: 'Logs',
shortcut: InfospectDesktopShortcuts.logsTab,
onSelected: () => run(selectLogs),
),
PlatformMenuItemGroup(
members: [
PlatformMenuItem(
label: 'Breakpoints…',
shortcut: InfospectDesktopShortcuts.breakpoints,
onSelected: () => run(openBreakpoints),
),
],
),
],
),
PlatformMenu(
label: 'Network',
menus: [
PlatformMenuItem(
label: 'Clear Network Calls',
shortcut: InfospectDesktopShortcuts.clearNetwork,
onSelected: () => run(clearNetwork),
),
PlatformMenuItem(
label: 'Share Network Calls',
shortcut: InfospectDesktopShortcuts.shareNetwork,
onSelected: () => run(shareNetwork),
),
PlatformMenuItemGroup(
members: [
PlatformMenuItem(
label: 'Open Network in New Window',
shortcut: InfospectDesktopShortcuts.popOutNetwork,
onSelected: () => run(popOutNetwork),
),
],
),
],
),
PlatformMenu(
label: 'Logs',
menus: [
PlatformMenuItem(
label: 'Clear Logs',
shortcut: InfospectDesktopShortcuts.clearLogs,
onSelected: () => run(clearLogs),
),
PlatformMenuItem(
label: 'Share Logs',
shortcut: InfospectDesktopShortcuts.shareLogs,
onSelected: () => run(shareLogs),
),
PlatformMenuItemGroup(
members: [
PlatformMenuItem(
label: 'Open Logs in New Window',
shortcut: InfospectDesktopShortcuts.popOutLogs,
onSelected: () => run(popOutLogs),
),
],
),
],
),
PlatformMenu(
label: 'Window',
menus: [
PlatformMenuItem(
label: 'Close Window',
shortcut: InfospectDesktopShortcuts.closeWindow,
onSelected: () => run(closeWindow),
),
],
),
];
}