luc
luc

Reputation: 1539

Flutter: How to show appbar above drawer?

I am building a flutter app and I don't find how to show appbar above drawer. I saw many people asking this but anybody solved it.

Upvotes: 0

Views: 156

Answers (1)

Jim
Jim

Reputation: 7601

Try this:

class _MyHomePageState extends State<MyHomePage> {
  final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: GestureDetector(
            child: Text('OPEN'),
            onTap: () {
              _scaffoldKey.currentState.openDrawer();
            }),
        title: Text(widget.title),
      ),
      body: Scaffold(
        key: _scaffoldKey,
        drawer: Drawer(),
        body: Container(),
      ),
    );
  }
}

Upvotes: 1

Related Questions