Flutter
[Flutter] AppBar 주요 요소
mjjayce
2025. 3. 28. 19:18
title
- AppBar 가운데 또는 왼쪽에 위치
- 페이지 제목, 앱 이름 등을 표시하는 데 사용
- centerTitle로 정렬 방향 조정 가능 ( centerTitle = true 인 경우 가운데 정렬)(안드로이드는 기본 false, ios는 기본 true)
예시
AppBar(
title: Text('Home'),
centerTitle: true,
)
leading
- AppBar 맨 왼쪽에 위치
- 뒤로가기 버튼, 햄버거 메뉴 아이콘에 주로 사용
예시
AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
)
뒤로가기 버튼 예시
actions
- AppBar 오른쪽에 위치
- 설정, 알림, 검색 아이콘 등에 주로 사용
예시
AppBar(
actions: [
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.settings),
onPressed: () {},
),
],
)
검색, 설정 아이콘 사용 예시