add latest price autocomplete
This commit is contained in:
parent
5f5487803b
commit
370a5329a9
2 changed files with 17 additions and 1 deletions
13
lib/api.dart
13
lib/api.dart
|
@ -184,6 +184,19 @@ class API {
|
|||
return resp.map((x) => Price(x)).toList();
|
||||
}
|
||||
|
||||
Future<Price> getLatestPrice(String item, String variant,
|
||||
{String? origin}) async {
|
||||
var url = "$instance/item/$item/$variant/price_latest";
|
||||
|
||||
if (origin != null) {
|
||||
url += "?origin=$origin";
|
||||
}
|
||||
|
||||
var resp = jsonDecode(await getRequest(url)) as Map<String, dynamic>;
|
||||
|
||||
return Price(resp);
|
||||
}
|
||||
|
||||
// Flows
|
||||
|
||||
// /flows
|
||||
|
|
|
@ -98,8 +98,11 @@ class _SupplyPageState extends State<SupplyPage> {
|
|||
.contains(textEditingValue.text.toLowerCase());
|
||||
});
|
||||
},
|
||||
onSelected: (String selection) {
|
||||
onSelected: (String selection) async {
|
||||
var price =
|
||||
await API().getLatestPrice(widget.item.id, variant);
|
||||
setState(() {
|
||||
_price = price.value.toStringAsFixed(2);
|
||||
_selectedOrigin = selection;
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue