import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false, // 디버그 표시 제거
title: 'Appbar',
theme: ThemeData(
primarySwatch: Colors.red,
),
home: MyPage(),
);
}
}
class MyPage extends StatelessWidget {
const MyPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Appbar 아이콘 메뉴"),
centerTitle: true,
elevation: 0.0,
actions: <Widget>[ // 한 개 이상의 위젯 위치
IconButton( // 앱 바 타이틀 왼쪽에 위치 - 버튼 이벤트 필요
icon: Icon(Icons.shopping_cart), // 메뉴 아이콘 표시
onPressed: () { // 클릭 이벤트 처리
print('Shapping cart button is clicked');
},
),
IconButton( // 앱 바 타이틀 왼쪽에 위치 - 버튼 이벤트 필요
icon: Icon(Icons.search), // 메뉴 아이콘 표시
onPressed: () { // 클릭 이벤트 처리
print('Search button is clicked');
},
)
],
),
drawer: Drawer( // 메뉴 추가 됨
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('김기태'),
accountEmail: Text('test@test.com'),
currentAccountPicture: CircleAvatar(
backgroundImage: AssetImage('assets/person.png'),
backgroundColor: Colors.white,
),
otherAccountsPictures: <Widget>[
CircleAvatar(
backgroundImage: AssetImage('assets/img2.gif'),
backgroundColor: Colors.white,
),
//CircleAvatar(
// backgroundImage: AssetImage('assets/img1.gif'),
// backgroundColor: Colors.white,
//),
],
onDetailsPressed: (){
print('arrow is clicked');
},
decoration: BoxDecoration(
color: Colors.red[200],
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40.0),
bottomRight: Radius.circular(40.0),
)
),
),
ListTile(
leading: Icon(Icons.home,
color: Colors.grey[850],
),
title: Text('Home'),
onTap: (){
print('Home is Clicked');
},
trailing: Icon(Icons.add),
),
ListTile(
leading: Icon(Icons.settings,
color: Colors.grey[850],
),
title: Text('Setting'),
onTap: (){
print('Setting is Clicked');
},
trailing: Icon(Icons.add),
),
ListTile(
leading: Icon(Icons.question_answer,
color: Colors.grey[850],
),
title: Text('Q&A'),
onTap: (){
print('Q&A is Clicked');
},
trailing: Icon(Icons.add),
),
],
),
),
);
}
}