Drawer Widget in Flutter

Properties

 

  • child
  • hashCode
  • elevation
  • semanticLabel

 

Example 1:

 

import 'package:flutter/material.dart';


void main() => DemoApp();


class DemoApp extends StatefulWidget {

  @override

  State<StatefulWidget> createState() {

    return DemoAppState();

  }

}


class DemoAppState extends State<DemoApp> {

  @override

  Widget build(BuildContext context) {

    return MaterialApp(

      home: Scaffold(

        appBar: AppBar(

          title: Text("Demo App"),

        ),

        drawer: Drawer(),

      ),

    );

  }

}

 

Example 2:

 

import 'package:flutter/material.dart';


void main() => DemoApp();


class DemoApp extends StatefulWidget {

  @override

  State<StatefulWidget> createState() {

    return DemoAppState();

  }

}


class DemoAppState extends State<DemoApp> {

  @override

  Widget build(BuildContext context) {

    return MaterialApp(

      home: Scaffold(

        appBar: AppBar(

          title: Text("Demo App"),

        ),

        drawer: Drawer(

          child: ListView(

            children: [

              DrawerHeader(

                decoration: BoxDecoration(

                  color: Colors.blue,

                ),

                child: Column(

                  children: [

                    ClipRRect(

                      child: Image.network(

                        "https://cdn.pixabay.com/photo/2021/01/29/08/10/musician-5960112_960_720.jF",

                        height: 100,

                        width: 100,

                      ),

                      borderRadius: BorderRadius.circular(20),

                    ),

                    Text('Pahul'),

                  ],

                ),

              ),

              Column(

                children: [

                  ListTile(

                    title: Text('Home'),

                    leading: Icon(Icons.home),

                  ),

                  ListTile(

                    title: Text('Account'),

                    leading: Icon(Icons.account_box),

                  ),

                  ListTile(

                    title: Text('Cart'),

                    leading: Icon(Icons.shopping_cart),

                  ),

                  ListTile(

                    title: Text('Logout'),

                    leading: Icon(Icons.logout),

                  ),

                ],

              ),

            ],

          ),

        ),

      ),

    );

  }

}


Video Link:

Post a Comment (0)
Previous Post Next Post