9.2 搜索栏
实现步骤:
第 1 步:搜索栏编写
lib/pages/goods/home/controller.dart
lib/pages/goods/home/view.dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| AppBar _buildAppBar() { return AppBar( backgroundColor: Colors.transparent, elevation: 0, titleSpacing: AppSpace.listItem, title: InputWidget.search( hintText: LocaleKeys.gHomeNewProduct.tr, onTap: controller.onAppBarTap, readOnly: true, ), actions: [ IconWidget.svg( AssetsSvgs.pNotificationsSvg, size: 20, isDot: true, ) .unconstrained() .padding( left: AppSpace.listItem, right: AppSpace.page, ), ], ); }
|
unconstrained
去掉约束
isDot
未读消息 小圆点,下面说
backgroundColor
背景透明
elevation
取消阴影
titleSpacing
标题栏左侧间距
actions
右侧的按钮区
第 2 步:图标加小圆点
lib/common/widgets/icon.dart
1 2 3 4 5
| class IconWidget extends StatelessWidget { ... final bool? isDot;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| @override Widget build(BuildContext context) { ...
if (isDot == true) { return Badge( position: BadgePosition.bottomEnd(bottom: 0, end: -2), elevation: 0, badgeColor: AppColors.primary, padding: const EdgeInsets.all(4.0), child: icon, ); }
|
提交代码到 git