* app_bar.dart
enum AppBarLeft { none, back }
enum AppBarRight { none, notify }
PreferredSizeWidget buildAppBar(BuildContext context,
{AppBarLeft left = AppBarLeft.none,
AppBarRight right = AppBarRight.none,
String title = '',
double height = 56}) {
return AppBar(
automaticallyImplyLeading: left == AppBarLeft.none ? false : true,
title: title.isEmpty ? null : Text(title),
toolbarHeight: height,
actions: right == AppBarRight.notify
? [NotifyButton()]
: null,
);
}
class NotifyButton extends StatefulWidget {
const NotifyButton({Key? key}) : super(key: key);
@override
_NotifyButtonState createState() => _NotifyButtonState();
}
class _NotifyButtonState extends State<NotifyButton> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: InnerConfig.normal - 12),
child: InkWell(
borderRadius: RadiusConfig.normal,
onTap: () {},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: SvgPicture.asset('assets/icons/bell.svg'))),
);
}
}
* Use
return Scaffold(
appBar: buildAppBar(
title: 'Title',
),
);
'App > Flutter' 카테고리의 다른 글
[ FLUTTER ] 패키지 네임 포함 프로젝트 생성 (0) | 2021.12.21 |
---|---|
[ FLUTTER 커스텀 ] Popup (0) | 2021.12.13 |
[ FLUTTER 커스텀 ] SliverAppBar (0) | 2021.12.13 |
[ FLUTTER 커스텀 ] ActiveButton (0) | 2021.12.13 |
[ FLUTTER ] WebView Package 지도 표시 (0) | 2021.11.26 |