Drawer App Sample Source Code



Hi guys... Welcome to my blog TechnoStar...

So today I am going to give you the source code of how to create a sample drawer app using flutter programming language.. Many of you may not be knowing what is flutter...

Actually flutter is a programming language using which you generate apps for both Android and IOS simultaneously with the same piece of code that can be run both in Android as well as IOS platform..

SOURCE CODE :

import 'package:flutter/material.dart';

void main() => runApp(myApp());

class myApp extends StatelessWidget {
  final appTitle='Drawer App';

  @override
  Widget build(BuildContext context){
    return MaterialApp (
      title: appTitle,
      home: MyHomePage(title: appTitle),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

  MyHomePage ({Key key, this.title}) : super (key: key);

  @override
  Widget build(BuildContext context){
    return Scaffold (
      appBar:AppBar(title: Text(title)),
      body: Center( child: Text('My Home Page')),
      drawer: Drawer(
        child: ListView(
          padding: EdgeInsets.zero,
          children:<Widget> [
            DrawerHeader(
              child:Text('Drawer Head'),
              decoration: BoxDecoration(
                color:Colors.blue,
              ),
            ),
            ListTile(
              title: Text('Item 1'),
              onTap: (){
                Navigator.pop(context);
              },
            ),
            ListTile(
              title:Text('Item 2'),
              onTap: () {
                Navigator.pop(context);
              },
            ),
          ],
        ),
      ),
    );
  }
}

Thank you for Watching and visiting...
 



Comments