multiple tags can add using space
This commit is contained in:
parent
ddb1440211
commit
4d2b05cdc2
@ -204,11 +204,37 @@ class _AddServiceProjectJobBottomSheetState
|
||||
height: 48,
|
||||
child: TextFormField(
|
||||
controller: controller.tagCtrl,
|
||||
textInputAction: TextInputAction.done,
|
||||
onEditingComplete: () {
|
||||
final raw = controller.tagCtrl.text.trim();
|
||||
if (raw.isEmpty) return;
|
||||
|
||||
final parts = raw
|
||||
.split(RegExp(r'[, ]+'))
|
||||
.map((s) => s.trim())
|
||||
.where((s) => s.isNotEmpty);
|
||||
|
||||
for (final p in parts) {
|
||||
if (!controller.enteredTags.contains(p)) {
|
||||
controller.enteredTags.add(p);
|
||||
}
|
||||
}
|
||||
controller.tagCtrl.clear();
|
||||
},
|
||||
onFieldSubmitted: (v) {
|
||||
final value = v.trim();
|
||||
if (value.isNotEmpty &&
|
||||
!controller.enteredTags.contains(value)) {
|
||||
controller.enteredTags.add(value);
|
||||
// also handle normal submit
|
||||
final raw = v.trim();
|
||||
if (raw.isEmpty) return;
|
||||
|
||||
final parts = raw
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.where((s) => s.isNotEmpty);
|
||||
|
||||
for (final p in parts) {
|
||||
if (!controller.enteredTags.contains(p)) {
|
||||
controller.enteredTags.add(p);
|
||||
}
|
||||
}
|
||||
controller.tagCtrl.clear();
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user