Skip to content

Instantly share code, notes, and snippets.

@mmanflori
Created February 9, 2019 01:30
Show Gist options
  • Save mmanflori/2beaa8a509f373cae85696cf109f9b44 to your computer and use it in GitHub Desktop.
Save mmanflori/2beaa8a509f373cae85696cf109f9b44 to your computer and use it in GitHub Desktop.
Drawer Example
import 'package:flutter/material.dart';
import 'ZweiterBildschirm.dart';
class Hauptbildschirm extends StatelessWidget {
GlobalKey<ScaffoldState>_scaffoldKey = new GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
leading: IconButton(icon: Icon(Icons.menu), onPressed: () {
_scaffoldKey.currentState.openDrawer();
}),
title: Text("Hauptbildschirm"),
actions: <Widget>[
IconButton(icon: Icon(Icons.search), onPressed: () {}),
],
),
body: Center(
child: RaisedButton(
child: Text(
"Nächster Bildschirm",
style: TextStyle(
color: Colors.white,
),
),
color: Colors.green,
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ZweiterBildschirm()),
);
},
),
),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text("Willkommen zurück",
style: TextStyle(
color:Colors.white,
)
),
decoration: BoxDecoration(
color: Colors.orange,
),
),
ListTile(
title: Text(
"Menu 1"
),
onTap: (){
Navigator.pop(context);
},
),
ListTile(
title: Text(
"Menu 2"
),
onTap: (){
Navigator.pop(context);
},
),
ListTile(
title: Text(
"Menu 3"
),
onTap: (){
Navigator.pop(context);
},
),
],
),
),
);
}
}
import 'package:flutter/material.dart';
import 'hauptbildschirm.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
canvasColor: Colors.white,
primarySwatch: Colors.green,
),
home: Hauptbildschirm(),
);
}
}
import 'package:flutter/material.dart';
class ZweiterBildschirm extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title:Text("Zweiter Bildschirm"),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment