1

Is it possible for me to open a page with icons when I click on the place I drew in red in the picture, like the bottomnavbar on Instagram, but I want mine to be like in the picture


Solution 1: Len_X

What you have to do is:

  • add a drawer to your scaffold
  • add a GlobalKey to your Widget which you will use to open the Drawer
  • Remove the AppBar Menu button if you don't want it there
  • Add a the button and Position it in your body
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  final appTitle = 'Drawer Demo';

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

class MyHomePage extends StatelessWidget {
  final String title;
  //Add GlobalKey which you will use to open the drawer
  final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      //Set GlobalKey
      key: _scaffoldKey,

      appBar: AppBar(title: Text(title), 
      //This will remove the AppBar menu button
      automaticallyImplyLeading: false,),
      body:
      Center(child: 
      Container(
        width: double.infinity,
        alignment: Alignment.centerLeft,
        child: InkWell(
          //This function will open the Side Menu
          onTap: ()=> _scaffoldKey.currentState?.openDrawer()
          ,
                  child: Icon(
            Icons.menu,
            size: 20,
          ),
        ),
      ),
            ),
      //Add Drawer to your Scaffold
      drawer: Drawer(
        child: ListView(
          padding: EdgeInsets.zero,
          children: <Widget>[
            DrawerHeader(
              decoration: BoxDecoration(
                color: Colors.blue,
              ),
              child: Text('Drawer Header'),
            ),
            ListTile(
              title: Text('Item 1'),
              onTap: () {
                Navigator.pop(context);
              },
            ),
            ListTile(
              title: Text('Item 2'),
              onTap: () {
                Navigator.pop(context);
              },
            ),
          ],
        ),
      ),
    );
  }
}