TEXT: FLUTTER - THE DRAWER (SIDEBAR MENU)

 The full code from the video:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(),
    );
  }
}

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Hello World'),
        centerTitle: true,
        titleTextStyle: const TextStyle(
          color: Colors.red,
          fontSize: 30.0,
        ),
        actions: [
          IconButton(
            icon: const Icon(Icons.home),
            onPressed: () {
              print('You clicked the home button');
            },
          ),
          IconButton(
            icon: const Icon(Icons.camera),
            onPressed: () {
              print('You clicked the camera button');
            },
          ),
        ],
        shadowColor: Colors.amber,
        backgroundColor: Colors.blue, //bgcolor of the AppBar Widget
        elevation: 0,
      ),
      //this is to change the background color of the body
      backgroundColor: Colors.white,
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Colors.black12,
        elevation: 10.0,
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.home_filled), label: "Home"),
          BottomNavigationBarItem(icon: Icon(Icons.camera), label: "Images"),
          BottomNavigationBarItem(icon: Icon(Icons.shop_2), label: "Shop"),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          print("You clicked the floating actoin button");
        },
        child: Icon(Icons.add),
        backgroundColor: Colors.blue,
      ),
      drawer: Drawer(
        child: Column(
          children: [
            const DrawerHeader(
              child: Icon(
                Icons.home_filled,
                size: 100.0,
              ),
            ),
            ListTile(
              leading: const Icon(Icons.phone_android),
              title: const Text("Contact Us"),
              onTap: () {
                print("You clicked the Contact Us Menu!");
                Navigator.pop(context);
              },
            ),
            ListTile(
              leading: const Icon(Icons.abc),
              title: const Text("Learn ABC"),
              onTap: () {
                print("You clicked the Alphabet Menu!");
                Navigator.pop(context);
              },
            ),
            ListTile(
              leading: const Icon(Icons.add_comment),
              title: const Text("Add Comment"),
              onTap: () {
                print("You clicked the Add Comment Menu!");
                Navigator.pop(context);
              },
            ),
          ],
        ),
      ),
      body: const Column(
        children: [
          Text('This is the first line'),
          Text('This is the second line'),
          Text('This is the third line'),
        ],
      ),
    );
  }
}


No comments:

Post a Comment

UNITY: USING FIREBALL TO ELIMINATE ENEMIES

 Code user in the video: Fireball Controller using System . Collections ; using System . Collections . Generic ; using UnityEngine ; publ...