Flutter/Flutter
Flutter - appBar에 drawer추가
hyeonseong
2023. 9. 4. 18:10
소스코드
- width의 값이 1024보다 클 경우 Desktop로 했다.
- Desktop일 경우 appBar는 없어진다.
- Appbar를 클릭하면 현재 페이지의 openDrawer를 호출해, SideMenu()를 연다.
(SideMenu는 개인적으로 만든 위젯)
appBar: Responsive.isDesktop(context) // Desktop이면 AppBar 숨김
? null
: AppBar(
backgroundColor: bgColor,
leading: Builder(builder: (context) {
return IconButton(
onPressed: () {
Scaffold.of(context).openDrawer();
},
icon: const Icon(Icons.menu),
);
}),
),
drawer: const SideMenu(),