|
|
|
|
@ -26,25 +26,26 @@ class OracleUserAutoCompleteField extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _AutoCompletePartsFieldState extends State<OracleUserAutoCompleteField> {
|
|
|
|
|
AssetDeliveryProvider? assetDeliveryProvider;
|
|
|
|
|
late TextEditingController _controller;
|
|
|
|
|
|
|
|
|
|
// late TextEditingController _controller;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
_controller = TextEditingController(text: widget.initialValue);
|
|
|
|
|
// _controller = TextEditingController(text: widget.initialValue);
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void didUpdateWidget(covariant OracleUserAutoCompleteField oldWidget) {
|
|
|
|
|
if (widget.initialValue != oldWidget.initialValue) {
|
|
|
|
|
_controller = TextEditingController(text: widget.initialValue);
|
|
|
|
|
}
|
|
|
|
|
// if (widget.initialValue != oldWidget.initialValue) {
|
|
|
|
|
// _controller = TextEditingController(text: widget.initialValue);
|
|
|
|
|
// }
|
|
|
|
|
super.didUpdateWidget(oldWidget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_controller.dispose();
|
|
|
|
|
// _controller.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -59,16 +60,18 @@ class _AutoCompletePartsFieldState extends State<OracleUserAutoCompleteField> {
|
|
|
|
|
// boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
|
|
|
|
),
|
|
|
|
|
child: Autocomplete<OracleUserModel>(
|
|
|
|
|
key: ValueKey(widget.initialValue),
|
|
|
|
|
optionsBuilder: (TextEditingValue textEditingValue) async {
|
|
|
|
|
if (textEditingValue.text.isEmpty) {
|
|
|
|
|
return const Iterable<OracleUserModel>.empty();
|
|
|
|
|
}
|
|
|
|
|
return await assetDeliveryProvider!.getOracleUserAutoCompleteDetails(query: textEditingValue.text);
|
|
|
|
|
},
|
|
|
|
|
initialValue: TextEditingValue(text: widget.initialValue),
|
|
|
|
|
displayStringForOption: (OracleUserModel option) => option.fullName ?? "",
|
|
|
|
|
fieldViewBuilder: (BuildContext context, TextEditingController fieldTextEditingController, FocusNode fieldFocusNode, VoidCallback onFieldSubmitted) {
|
|
|
|
|
return TextField(
|
|
|
|
|
controller: _controller,
|
|
|
|
|
controller: fieldTextEditingController,
|
|
|
|
|
focusNode: fieldFocusNode,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.black10),
|
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
|
@ -101,11 +104,11 @@ class _AutoCompletePartsFieldState extends State<OracleUserAutoCompleteField> {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onSelected: (OracleUserModel selection) {
|
|
|
|
|
if (widget.clearAfterPick) {
|
|
|
|
|
_controller.clear();
|
|
|
|
|
} else {
|
|
|
|
|
_controller.text = selection.fullName ?? '';
|
|
|
|
|
}
|
|
|
|
|
// if (widget.clearAfterPick) {
|
|
|
|
|
// fieldTextEditingController.clear();
|
|
|
|
|
// } else {
|
|
|
|
|
// _controller.text = selection.fullName ?? '';
|
|
|
|
|
// }
|
|
|
|
|
widget.onPick(selection);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
|