Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- text
- 웹크롤러
- function
- set
- Android
- 클래스
- DART
- 콜렉션
- 함수
- Class
- package
- 파이썬
- ML
- Collection
- List
- import
- Flutter
- 크롤러
- animation
- variable
- 다트
- 플러터
- python
- textstyle
- crawler
- kotlin
- map
- pushnamed
- 코틀린
- texttheme
Archives
- Today
- Total
조용한 담장
Drawer 본문
Drawer
DrawerHeader, Drawer
DrawerHeader 는 Material design에서 Drawer의 맨 위 공간으로 사용자의 정보등을 표시하는 용도로 사용하는 경우를 흔히 볼 수 있다.
Drawer 에는 DrawerHeader, ListTile, Divider, Card, AboutListTile 등을 배치해 꾸며보았다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Flutter Demo Home Page'), | |
), | |
body: Container(), | |
drawer: Drawer( | |
child: ListView( | |
padding: EdgeInsets.zero, | |
children: <Widget>[ | |
DrawerHeader( | |
child: Text('Drawer Header'), | |
decoration: BoxDecoration( | |
color: Colors.blue, | |
), | |
), | |
ListTile( | |
title: Text('Item 1'), | |
leading: FlutterLogo(), | |
selected: true, | |
), | |
ListTile( | |
title: Text('one-line with trailing widget'), | |
trailing: Icon(Icons.more_vert), | |
), | |
ListTile( | |
title: Text('one-line with leading widget'), | |
leading: Icon(Icons.thumb_up), | |
), | |
Divider( | |
color: Colors.blue, | |
), | |
Card( | |
child: ListTile( | |
title: Text('One-line ListTile'), | |
), | |
), | |
Card( | |
child: ListTile( | |
title: Text('two-line ListTile'), | |
subtitle: Text('subtitle line'), | |
leading: Icon(Icons.thumbs_up_down), | |
trailing: Icon(Icons.more_vert), | |
), | |
), | |
Divider( | |
color: Colors.blue, | |
), | |
AboutListTile( | |
applicationName: 'Drawer Demo', | |
applicationIcon: FlutterLogo(), | |
applicationVersion: '1.0', | |
applicationLegalese: 'Free', | |
), | |
Container( | |
color: Colors.lightBlue[200], | |
height: 50.0, | |
child: FlatButton( | |
child: Text('Close Drawer'), | |
onPressed: () { | |
Navigator.pop(context); | |
}, | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |



Tap actions
Dialog 를 삽입해서 Tap 기능을 동작시켜 보았다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomePageState extends State<MyHomePage> { | |
AlertDialog _dialog(String title) { | |
return AlertDialog( | |
title: Text(title), | |
actions: <Widget>[ | |
FlatButton( | |
child: Text('back'), | |
onPressed: () { | |
Navigator.pop(context); | |
}, | |
), | |
], | |
); | |
} | |
// ... | |
} |
onTap, onLongPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ListTile( | |
title: Text('Item 1'), | |
leading: FlutterLogo(), | |
onTap: () { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return _dialog('Tapped Item 1'); | |
} | |
); | |
}, | |
onLongPress: () { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return _dialog('LongPress'); | |
} | |
); | |
}, | |
selected: true, | |
), |


GestureDetector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ListTile( | |
title: Text('one-line with leading widget'), | |
leading: GestureDetector( | |
onTap: () { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return _dialog('Tapped leading'); | |
} | |
); | |
}, | |
child: Icon(Icons.thumb_up), | |
), | |
), |

endDrawer
오른쪽에서 열리는 Drawer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
// ... | |
endDrawer: Drawer( | |
child: Center(child: Text('This is endDrawer')), | |
), | |
); | |
} |


Demo

Reference
https://flutter.dev/docs/cookbook/design/drawer
https://api.flutter.dev/flutter/material/Drawer-class.html
https://api.flutter.dev/flutter/material/DrawerHeader-class.html
'Flutter' 카테고리의 다른 글
url_launcher (0) | 2019.08.07 |
---|---|
Flutter : Platform-specific code (0) | 2019.08.06 |
AnimatedSwitcher (0) | 2019.07.31 |
BottomNavigationBar, BottomAppBar (0) | 2019.07.29 |
Tab (0) | 2019.07.24 |