Friday, February 12, 2021

【FLUTTER ANDROID STUDIO and IOS】 Drawer

void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: new Drawer(
child: new ListView(
padding: EdgeInsets.zero,
children: <Widget>[
new DrawerHeader(
child: new Text("Header"),
decoration: new BoxDecoration(color: Colors.blue),
),
new ListTile(
title: new Text("Item 1"),
onTap: () {
Navigator.pop(context);
},
),
new ListTile(
title: new Text("Item 2"),
onTap: () {
Navigator.pop(context);
},
)
],
),
),
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Hello World!',
),
],
),
),
);
}
}
view raw main.dart hosted with ❤ by GitHub

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Generate a catchy title for a collection of newfangled music by making it your own

Write a newfangled code fragment at an earlier stage to use it. Then call another method and make sure their input is the correct one. The s...