Day 17 Of Flutter - Debugging, PopupMenu Widgets

On day 17, I worked on the log out function and the main view of my app. With this I learned about debugging, the PopupMenuButton and Item.

PopupMenuButton

A popupMenuButton is a type of button that displays a list of options when pressed. They present the user with a set of actions or choices to be selected from a drop-down menu. The popup menu of popupMenuButton is populated using the popupMenuItem. I used this widget to kickstart the log-out process of my notes app. To complete the process, I write a Future<bool> function that presents the user with an alert dialog with buttons for the user to confirm logging out or cancelling.

Print And Log Statements

Print and log statements are two of the ways to identify and fix errors in our app. The print() function is used to display a message in the console. It can be used to check if functions are being called and to monitor the control flow of an app. This is done by printing the values of variables.

Logging is used for more complicated debugging. To access the log() function one has to import 'dart:developer' package.

Print statements are not the best practice, especially for production code, since they clutter your code and can have an impact on your app's performance if used excessively. Print statements cannot also be stored in a database, i.e., they can get lost in the event of an app crash.