mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-11-08 20:50:04 +00:00
added: navigation_drawer example
This commit is contained in:
45
navigation_drawer/lib/main.dart
Normal file
45
navigation_drawer/lib/main.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(home: new MyDrawerApp()));
|
||||
}
|
||||
|
||||
class MyDrawerApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ListView listView = new ListView(
|
||||
children: <Widget>[
|
||||
getPaddedFirstText("Nav Item 1"),
|
||||
getPaddedText("Nav Item 2"),
|
||||
getPaddedText("Nav Item 3"),
|
||||
getPaddedText("Nav Item 4"),
|
||||
],
|
||||
);
|
||||
Drawer myDrawer = new Drawer(
|
||||
child: listView,
|
||||
);
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("Navigation Drawer Example"),
|
||||
),
|
||||
body: new Container(
|
||||
child: new Center(
|
||||
child: new Text("Hello World!"),
|
||||
)),
|
||||
drawer: myDrawer,
|
||||
);
|
||||
}
|
||||
|
||||
Padding getPaddedFirstText(var data) {
|
||||
return new Padding(
|
||||
child: new Text(data),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15.0, right: 15.0, bottom: .0, top: 40.0));
|
||||
}
|
||||
|
||||
Padding getPaddedText(var data) {
|
||||
return new Padding(
|
||||
child: new Text(data), padding: const EdgeInsets.all(15.0));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user