관리 메뉴

Bull

[Flutter::Widget] Drawer icon 변경 방법! 본문

Software Framework/Flutter

[Flutter::Widget] Drawer icon 변경 방법!

Bull_ 2024. 8. 14. 20:26

https://stackoverflow.com/questions/59554348/how-can-i-change-drawer-icon-in-flutter

 

How can I change Drawer icon in flutter?

The drawer has this default three horizontal bars as default icon but I want to change it to something else. I have checked the possible options under the Drawer(), but no property seems to be atta...

stackoverflow.com

검색어

"Drawer icon flutter"

변경 방법

Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text('hi'),
      leading: IconButton(
        icon: Icon(Icons.accessible),
        onPressed: () => Scaffold.of(context).openDrawer(),
      ),
    ),
    drawer: Drawer(),
  );
}

drawer 프로퍼티는 Scaffold 위젯의 프로퍼티라서 appBar의 프로퍼티로 들어가지는 않지만 appBarleading 프로퍼티를 통해서 아이콘을 지정해줄 수 있다.

 

문서를 딱히 찾아보진 않았지만 drawer프로퍼티는 코드에 있는 onPressed 에 적힌 메소드 호출 부분을 구현시켜 놓았다고 생각해도 좋을 것 같다!

바뀐 drawer icon의 모습