Widget selectVehicle() {
return Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 0.0, right: 0.0, top: 10.0),
child: Row(
children: <Widget>[
WidgetAnimator(
Text(
LocaleText.of(context).vehicle,
textAlign: TextAlign.left,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
),
),
],
mainAxisAlignment: MainAxisAlignment.start,
),
),
DecoratedBox(
decoration: ShapeDecoration(
color: Colors.transparent,
shape: RoundedRectangleBorder(
side: BorderSide(
width: 3.0,
style: BorderStyle.solid,
color: Theme.of(context).textTheme.caption.color),
borderRadius: BorderRadius.all(Radius.circular(10.0)),
),
),
child: Padding(
padding: const EdgeInsets.only(top: 0.0, left: 0, right: 0),
//child: SearchableDropdown(
child: SearchChoices.single(
hint: Text(
'${selectedVehicle['name'] != null ? selectedVehicle['name'] : LocaleText.of(context).unassigned}',
style: new TextStyle(
fontSize: 14,
color: Theme.of(context).textTheme.subtitle2.color,
),
overflow: TextOverflow.ellipsis,
),
underline: SizedBox(),
key: UniqueKey(),
items: devicesList?.map((item) {
return new DropdownMenuItem<dynamic>(
child: ListWidgetAnimator(
Text(
'${item['name']} ${item['brand']} ${item['model']}',
style: new TextStyle(
fontSize: 14,
color: Theme.of(context).textTheme.subtitle2.color,
),
overflow: TextOverflow.ellipsis,
),
),
value: item);
})?.toList(),
selectedValueWidgetFn: (item) {
return Container(
transform: Matrix4.translationValues(0, 0, 0),
alignment: Alignment.centerLeft,
child: Text(
'${item['name']} ${item['brand']} ${item['model']}',
style: new TextStyle(
fontSize: 16,
color: Theme.of(context).textTheme.subtitle2.color,
),
overflow: TextOverflow.ellipsis,
),
);
},
menuBackgroundColor: Theme.of(context).textTheme.headline4.color,
isExpanded: true,
value: selectedVehicle,
isCaseSensitiveSearch: false,
searchHint: new Text(
LocaleText.of(context).selectEquipmentError,
overflow: TextOverflow.ellipsis,
style: new TextStyle(
fontSize: 14,
),
),
searchFn: (String keyword, items) {
List<int> ret = List<int>();
if (keyword != null && items != null && keyword.isNotEmpty) {
keyword.split(" ").forEach((k) {
int i = 0;
items.forEach((item) {
if (k.isNotEmpty &&
(item.value['name']
.toString()
.toLowerCase()
.contains(k.toLowerCase()) ||
item.value['brand']
.toString()
.toLowerCase()
.contains(k.toLowerCase()) ||
item.value['model']
.toString()
.toLowerCase()
.contains(k.toLowerCase()) ||
item.value['description']
.toString()
.toLowerCase()
.contains(k.toLowerCase()))) {
ret.add(i);
}
i++;
});
});
}
if (keyword.isEmpty) {
ret = Iterable<int>.generate(items.length).toList();
}
return (ret);
},
closeButton: LocaleText.of(context).cancel,
onChanged: (value) {
// Hide keyboard
FocusScope.of(context).unfocus();
if (value != null) {
selectedVehicle = value;
if (mounted)
setState(() {
});
}
},
),
),
),
],
);
}```