Flutter Development 003

This slideshow requires JavaScript.

Today I set up the drawer in the Flutter app. The drawer is composed of 2 things: a hamburger menu button and a drawer with the list of options for the app.

Here’s the code I used to set up the drawer in the app:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MainView()
    );
  }
}

class MainView extends StatelessWidget {

  static const String _title = 'Manoa Career Center';

  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(
          title: const Text(_title),
        ),
        drawer: Drawer(
          child: ListView(
            padding: EdgeInsets.zero,
            children: [
              DrawerHeader(
                child: Text(''),
                decoration: BoxDecoration(
                  color: Colors.blue,
                ),
              ),
              ListTile(
                title: Text(
                  'View Employers',
                  style: TextStyle(fontSize: 20.0,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
              ListTile(
                title: Text(
                  'View Fair Map',
                  style: TextStyle(fontSize: 20.0,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
              ListTile(
                title: Text(
                  'Links',
                  style: TextStyle(fontSize: 20.0,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
              ListTile(
                title: Text(
                  'SIGN IN',
                  style: TextStyle(fontSize: 12.0,
                  ),
                ),
              ),
              ListTile(
                title: Text(
                  'SIGN UP',
                  style: TextStyle(fontSize: 12.0,
                  ),
                ),
              ),
              ListTile(
                title: Text(
                  'RESET PASSWORD',
                  style: TextStyle(fontSize: 12.0,
                  ),
                ),
              ),
            ],
          ),
        ),
        body: HomePageWidget(),
      ),
    );
  }
}

class HomePageWidget extends StatefulWidget {
  HomePageWidget({Key key}) : super(key: key);

  @override
  _HomePageWidgetState createState() {
    return _HomePageWidgetState();
  }
}


class _HomePageWidgetState extends State {

  @override
  Widget build(BuildContext context) {

    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [

        ],
      ),
    );
  }
}

Contact me if you have any questions!

Author: David Neely

Professional Software Developer. Technology and Web Coordinator at the University of Hawaii's Manoa Career Center.