Display Drawer in Flutter

Display Drawer in Flutter

A drawer is a sliding menu that is used to display navigation items. A drawer appears when the user swipes a finger from the left edge of the screen or when the user clicks the icon in the app bar.

A drawer can be created using Drawer class. It usually used with the Scaffold.drawer property. Typically a LisView is used as a child of the drawer. Often a LisView is constructed with DrawerHeader that displays heading information. A ListTitle widgets usually used to display navigation items.

import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  State<MyApp> createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Drawer')),
      drawer: Drawer(
          child: ListView(
        children: const <Widget>[
            decoration: BoxDecoration(color: Colors.black12),
            child: Text('Drawer header'),
          ListTile(title: Text('Account')),
          ListTile(title: Text('Call')),
          ListTile(title: Text('Camera')),

Leave a Comment

Cancel reply

Your email address will not be published.