buildAppBar function

PreferredSizeWidget buildAppBar(
  1. VoidCallback toggleSidebar,
  2. String userEmail,
  3. VoidCallback onLogout
)

Builds the AppBar widget for the application.

The AppBar contains a logo, a menu button to toggle the sidebar, and the user's email with an account icon in the actions section.

The toggleSidebar function is used to open/close the sidebar when the menu button is pressed. The userEmail is the email address of the currently logged-in user and is displayed next to the account icon.

Returns a PreferredSizeWidget that is used to display the AppBar.

Implementation

PreferredSizeWidget buildAppBar(
    VoidCallback toggleSidebar,
    String userEmail,
    VoidCallback onLogout,
    ) {
  return AppBar(
    backgroundColor: const Color(0xFF181A1B),
    title: Image.asset('assets/images/login/fetosense.png', height: 30),
    leading: IconButton(
      key: const Key('toggleSidebarButton'),
      icon: Icon(Icons.menu, color: Colors.grey[600]),
      onPressed: toggleSidebar,
    ),
    actions: [
      Padding(
        padding: const EdgeInsets.only(right: 16),
        child: UserMenu(
          email: userEmail,
          onLogout: onLogout,
        ),
      ),
    ],
  );
}