Files
jiu/client/lib/widgets/search_chip.dart
T
wangjia a678c3806e
Deploy Client / build-client-web (push) Successful in 44s
Deploy Client / build-macos (push) Successful in 2m29s
Deploy Client / build-android (push) Successful in 1m23s
Deploy Client / build-ios (push) Successful in 2m59s
Deploy Client / build-windows (push) Successful in 1m52s
Deploy Client / release-deploy-client (push) Successful in 2m40s
chore: release client-v1.0.79
入库/出库单搜索框升级:搜索后关键词转为框内 chip 标签 + 一键清除(✕),仅保留单个搜索词;新增 SearchChip 组件 + provider currentKeyword getter 进屏同步。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ4DskSRKsSiheQonFtQvx
2026-06-24 12:08:55 +08:00

53 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
/// 搜索框内嵌的「已生效搜索词」标签:紧凑圆角 chip + ✕ 删除按钮。
///
/// 用于列表屏搜索框 [InputDecoration.prefix],仅展示单个搜索词;
/// 点 ✕ 触发 [onDeleted] 清除搜索。
class SearchChip extends StatelessWidget {
const SearchChip({super.key, required this.label, required this.onDeleted});
final String label;
final VoidCallback onDeleted;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final bg = theme.colorScheme.primary.withValues(alpha: 0.12);
final fg = theme.colorScheme.primary;
return Container(
padding: const EdgeInsets.only(left: 8, right: 2, top: 2, bottom: 2),
decoration: BoxDecoration(
color: bg,
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 120),
child: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12,
color: fg,
fontWeight: FontWeight.w500,
),
),
),
InkResponse(
onTap: onDeleted,
radius: 14,
child: Padding(
padding: const EdgeInsets.all(2),
child: Icon(Icons.close, size: 14, color: fg),
),
),
],
),
);
}
}