-1

How to add drawer at top left corner without appbar, when i tried using positioned widget and Iconbutton and use Drawer as widget function, but it not working. Is there any other method??


class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  Widget drawer() {
    return Drawer();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.lightBlue,
      body: SafeArea(
        child: Positioned(
          top: 2,
          left: 2,
          child: IconButton(
            icon: Icon(
              Icons.menu,
            ),
            onPressed: () {
              drawer();
            },
          ),
        ),
      ),
    );
  }
}
Murali Krishnan
  • 272
  • 5
  • 20

1 Answers1

0

GlobalKey<ScaffoldState> _scaffoldState = GlobalKey<ScaffoldState>();

return Scaffold(
  key: _scaffoldState,
  drawer: DrawerView(),
  body: ThemeScreen(
    header: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        IconButton(
          icon: Icon(Icons.menu,
              color: Colors.white,
              size: 15),
          onPressed: (){
            _scaffoldState.currentState.openDrawer();
          },
        ),
      ],
    ),
  ),
);