Home > Back-end >  Show bottom navigation bar upon toggling drawer
Show bottom navigation bar upon toggling drawer

Time:09-22

How do I show my bottom navigation bar only when I toggle my drawer just like how Discord work? I tried looking for answer here but none of them really help

BottomNavBar.dart

import 'package:flutter/material.dart';

class BottomNavBar extends StatelessWidget {
  const BottomNavBar({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return BottomNavigationBar(
        items: [
          //some BottomNavBar items
        ]
    );
  }
}

Drawer.dart

class NavigationDrawer extends StatelessWidget {
  const NavigationDrawer({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Widget buildHeader(BuildContext context) => Material(
          //some header
        ),
      ),
    );

    Widget buildMenuItems(BuildContext context) => Container(
      padding: EdgeInsets.all(16),
      child: Wrap(
          children: [
              //some menu items
          ],
      ),
    );

    return SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          buildHeader(context),
          buildMenuItems(context),
        ],
      ),
    );
  }
}

CodePudding user response:

I will suggest you use a condition, like 'toggled == true ? shownavbar : null'. This is the first thing that comes to mind, but if it doesn't help let me know. So I can look at the code more closely. I hope this helps :)

  • Related