multiple tags can add using space
This commit is contained in:
parent
ddb1440211
commit
4d2b05cdc2
@ -204,11 +204,37 @@ class _AddServiceProjectJobBottomSheetState
|
|||||||
height: 48,
|
height: 48,
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: controller.tagCtrl,
|
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) {
|
onFieldSubmitted: (v) {
|
||||||
final value = v.trim();
|
// also handle normal submit
|
||||||
if (value.isNotEmpty &&
|
final raw = v.trim();
|
||||||
!controller.enteredTags.contains(value)) {
|
if (raw.isEmpty) return;
|
||||||
controller.enteredTags.add(value);
|
|
||||||
|
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();
|
controller.tagCtrl.clear();
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user