728x90
반응형
SMALL
# Flutter Drawer Widget
import 'package:flutter/material.dart'; /* Drawer Widget을 사용하려면 Scaffild Widget 을 사용해야 함 # Drawer Widget 만드는 순서 1. Create a Scaffold 2. Add a drawer 3. Populate the drawer with items 4. Close the drawer programmatically */ class DrawerEx01 extends StatefulWidget { _DrawerEx01State createState() => _DrawerEx01State(); } class _DrawerEx01State extends State<DrawerEx01> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('DrawerEx01'), ), drawer: Drawer( child: ListView( // Important: Remove any padding from the ListView. padding: EdgeInsets.zero, children: <Widget>[ DrawerHeader( child: Text('Drawer Header'), decoration: BoxDecoration( color: Colors.blue, ), ), ListTile( title: Text('Item 1'), onTap: () { // Update the state of the app Navigator.pop(context); }, ), ListTile( title: Text('Item 2'), onTap: () { // Update the state of the app Navigator.pop(context); }, ), ], ), ), body: Center( child: GestureDetector( onTap: () { Navigator.pop(context); }, child: Container( child: Padding( padding: const EdgeInsets.all(8.0), child: Text( 'Back', style: TextStyle( color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(10.0)), ), ), ), ); } } | cs |
728x90
반응형
LIST
'Program > Flutter' 카테고리의 다른 글
Flutter SnackBars Example 02 (0) | 2018.11.13 |
---|---|
Flutter SnackBars Example 01 (0) | 2018.11.13 |
Flutter Fade Animation Example (0) | 2018.11.13 |
Flutter List Widget Ex04 (0) | 2018.11.09 |
Flutter List Widget Ex03 (0) | 2018.11.09 |