feat: add input validation to search, update agent card layout, and extend ProfileFormField with input constraints

This commit is contained in:
pradeepkumar
2026-04-20 09:39:10 +05:30
parent 7cacc19c8e
commit 2e789aaf47
3 changed files with 34 additions and 10 deletions

View File

@@ -187,6 +187,7 @@ class _AgentSearchScreenState extends ConsumerState<AgentSearchScreen> {
),
),
onSubmitted: (value) {
if (value.trim().isEmpty) return;
ref.read(searchAgentsProvider.notifier).search(value);
},
),
@@ -196,13 +197,24 @@ class _AgentSearchScreenState extends ConsumerState<AgentSearchScreen> {
const SizedBox(width: 0),
GestureDetector(
onTap: () {
ref
.read(searchAgentsProvider.notifier)
.search(_searchController.text);
final query = _searchController.text.trim();
if (query.isEmpty) {
// No input — don't trigger a refresh
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Please enter a keyword'),
behavior: SnackBarBehavior.floating,
duration: Duration(seconds: 2),
),
);
return;
}
ref.read(searchAgentsProvider.notifier).search(query);
},
child: Container(
width: 62,
height: 42,
alignment: Alignment.center,
decoration: BoxDecoration(
color: AppColors.accentOrange,
border: Border.all(
@@ -211,12 +223,10 @@ class _AgentSearchScreenState extends ConsumerState<AgentSearchScreen> {
),
borderRadius: BorderRadius.circular(7),
),
child: Center(
child: SvgPicture.string(
'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="white"/></svg>',
width: 24,
height: 24,
),
child: const Icon(
Icons.search,
color: Colors.white,
size: 24,
),
),
),