logo-img

Shopping cart

Subtotal:

$78.00

Flutter - Create a Drawer for Android and iOS

What is Drawer?

In Flutter, a Drawer is a widget that slides in from the left or right side of the screen to display a menu or a set of options. The Drawer widget is typically used to provide access to navigation links, settings, user profiles, and other app-specific functions.

IOS & Android Drawer
  • In the lib directory, create a new file called my_drawer.dart where we will define our main widget.
  • In the my_blog.dart file, import the necessary Flutter packages:
  • Create a new class called SVTDrawer that extends StatelessWidget. This class will define our main widget.
  • Spire View Tech
  • You will get output like this :
  • Spire View Tech
  • In the SVTDrawer class, we have defined a Scaffold widget that contains an AppBar, a Drawer, and a Center widget as the main body.
  • In the AppBar widget, we have set the title of our blog.
  • In the Drawer widget, we have defined a UserAccountsDrawerHeader widget at the top, which displays the user's name, email, and profile picture.
  • Spire View Tech
  • Inside the Column, we have created three ListTile widgets for the blog posts, each with a title, subtitle, and trailing icon. We have also added a Divider widget between each post to visually separate them.
  • The title property is used to display the title of the blog post, while the subtitle property is used to display the date that the blog post was posted. The trailing property is used to display an arrow icon on the right side of the ListTile, which indicates that the user can tap on the ListTile to navigate to the blog post.
  • When the user taps on a ListTile, the onTap callback is called, where you can perform some action, such as navigating to the corresponding blog post page.
  • Spire View Tech
  • Implementing Multiple Menu
  • Spire View Tech
  • Full Drawer Code
  • Spire View Tech Spire View Tech
  • Output
  • Spire View Tech