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

08. Challenge: Add Delete List Menu

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: 07. System Menu Coding: Part 2 Next episode: 09. Macintosh Entitlements

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

Now that you know how to create and show menus, you can show your knowledge by accepting this challenge:

Challenge Solution

How was it? Easy? Difficult? Let’s go ahead and show how to do this. If you look through the code, you will see a method named: areYouSureDelete. This will show a dialog promting the user to answer Yes or No. In order to use this dialog you’ll need a context. Searching through the code shows that we can get the current context from the global navigatorKey: navigatorKey.currentContext.

Android Studio

Here’s the full code:

final listController = ref.read(listControllerProvider);
final todoList = listController.currentList;
if (todoList.name != 'empty') {
  areYouSureDelete(navigatorKey.currentContext!,
      'Are you sure you want to delete ${todoList.name}',
          (deleted) {
        if (deleted) {
          final repository = ref.read(repositoryProvider);
          repository.deleteTodoList(todoList);
        }
      });
}