How To Use Right And Left Navigation Drawer In Flutter

admin_img Posted By Bajarangi soft , Posted On 27-11-2020

In this android programming source code example, we are going to change the color of navigation drawer indicator icon in android. You can copy and adopt this. In this android programming source code example, we are going to change the color of navigation drawer indicator icon in android. You can copy and adopt this source code example to your android project without reinventing the wheel. Below is a step by step source code to change the color of navigation drawer indicator icon in android.

How To Use Right And Left Navigation Drawer In Flutter

Right And Left Navigation Drawer 
Complete COde For Right And Left Navigation Drawer  In Flutter
main.dart

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.red,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  var _scaffoldKey = new GlobalKey<ScaffoldState>();
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      key: _scaffoldKey,
      drawer: new AppDrawer(),
      endDrawer: new AppDrawer(),
      appBar: new AppBar(
        title: new Text("Right And Left Drawer"),
      ),
      body: new ListView(
        children: <Widget>[
          new ListTile(
            title: new Text("Body"),
          ),
        ],
      ),
    );
  }
}


class AppDrawer extends StatefulWidget {
  @override
  _AppDrawerState createState() => new _AppDrawerState();
}

class _AppDrawerState extends State<AppDrawer> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: 250,
      child: new Drawer(
        child: Container(
          color: Colors.red[800],
          child: ListView(
            padding: EdgeInsets.all(10.0),
            children: [
              ListTile(
                leading: Icon(Icons.home, color: Colors.white,),
                title: Text('Home',style: TextStyle(color: Colors.white),),
              ),
              ListTile(
                leading: Icon(Icons.person, color: Colors.white,),
                title: Text('Profile',style: TextStyle(color: Colors.white),),
              ),
              ListTile(
                leading: Icon(Icons.phone, color: Colors.white,),
                title: Text('Contact',style: TextStyle(color: Colors.white),),
              ),
              ListTile(
                leading: Icon(Icons.settings, color: Colors.white,),
                title: Text('Setting',style: TextStyle(color: Colors.white),),
              ),
              ListTile(
                leading: Icon(Icons.help_outline, color: Colors.white,),
                title: Text('Help',style: TextStyle(color: Colors.white),),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Related Post