본문 바로가기
개발/Flutter

Flutter 플러터 Appbar 간단 사용법

by SPNK 2022. 12. 24.
반응형

Appbar

  • centerTitle : 텍스트 가운데 정렬 여부
  • automaticallyImplyLeading : 뒤로가기 버튼 제거 여부
  • elevation : 그림자 제거
  • backgroundColor : 배경 색
  • title : 제목
  • leading : 왼쪽 아이콘 버튼
  • actions : 오른쪽 아이콘 버튼

 

  • 예시 코드
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        automaticallyImplyLeading: true,
        elevation: 0,
        backgroundColor: Colors.white,
        title: Text("제목"),
        leading: IconButton(
          icon: Icon(Icons.star, color: Colors.black),
          onPressed: () {
            print("왼쪽 위 아이콘 클릭");
          },
        ),
        actions: [
          IconButton(
            icon: Icon(Icons.star, color: Colors.black),
            onPressed: () {
              print("오른쪽 아이콘 클릭 1");
            },
          ),
          IconButton(
            icon: Icon(Icons.star, color: Colors.black),
            onPressed: () {
              print("오른쪽 아이콘 클릭 2");
            },
          ),
        ],
      ),
    );
  }
반응형

댓글