Flutter Desktop Apps: Getting Started

Mar 28 2023 · Dart 2.19, Flutter 3.7, Android Studio 2021.3.1 or higher, Visual Studo Code 1.7.4 or higher

Part 1: Flutter Desktop Apps

07. System Menu Coding: Part 2

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 06. System Menu Coding: Part 1 Next episode: 08. Challenge: Add Delete List Menu

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Android Studio

Now that you have the first two menus implemented, you will create the last three. First, let’s add the methods to the menu creation methods:

createTodosMenu(),
createFindMenu(),
createHelpMenu()
createWindowsTodosMenu(),
createWindowsFindMenu(),
createWindowsHelpMenu()
PlatformMenu createTodosMenu() {
  return PlatformMenu(label: 'Todos', menus: [
    PlatformMenu(label: 'New', menus: [
      PlatformMenuItem(label: 'List', onSelected: () => newList()),
      PlatformMenuItem(label: 'Category', onSelected: () => newCategory()),
      PlatformMenuItem(label: 'Todo', onSelected: () => newTodo()),
    ]),
    PlatformMenu(label: 'Delete', menus: [
      PlatformMenuItem(label: 'List', onSelected: () => deleteList()),
      PlatformMenuItem(label: 'Category', onSelected: () => deleteCategory()),
      PlatformMenuItem(label: 'Todo', onSelected: () => deleteTodo()),
    ])
  ]);
}
NativeSubmenu createWindowsTodosMenu() {
  return NativeSubmenu(label: 'Todos', children: [
    NativeSubmenu(label: 'New', children: [
      NativeMenuItem(label: 'List', onSelected: () => newList()),
      NativeMenuItem(label: 'Category', onSelected: () => newCategory()),
      NativeMenuItem(label: 'Todo', onSelected: () => newTodo()),
    ]),
    NativeSubmenu(label: 'Delete', children: [
      NativeMenuItem(label: 'List', onSelected: () => deleteList()),
      NativeMenuItem(label: 'Category', onSelected: () => deleteCategory()),
      NativeMenuItem(label: 'Todo', onSelected: () => deleteTodo()),
    ])
  ]);
}
PlatformMenu createFindMenu() {
  return PlatformMenu(label: 'Find', menus: [
    PlatformMenuItem(label: 'Search', onSelected: () => handleSearch()),
    PlatformMenuItem(label: 'Next', onSelected: () => handleNext()),
    PlatformMenuItem(label: 'Previous', onSelected: () => handlePrevious())
  ]);
}
NativeSubmenu createWindowsFindMenu() {
  return NativeSubmenu(label: 'Find', children: [
    NativeMenuItem(label: 'Search', onSelected: () => handleSearch()),
    NativeMenuItem(label: 'Next', onSelected: () => handleNext()),
    NativeMenuItem(label: 'Previous', onSelected: () => handlePrevious())
  ]);
}
PlatformMenu createHelpMenu() {
  return PlatformMenu(
      label: 'Help',
      menus: [PlatformMenuItem(label: 'Help', onSelected: () => handleHelp())]);
}
NativeSubmenu createWindowsHelpMenu() {
  return NativeSubmenu(label: 'Help', children: [
    NativeMenuItem(label: 'Help', onSelected: () => handleHelp())
  ]);
}