mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Returning object list now works correctly (and asynchronously!)
This commit is contained in:
parent
0ee1dedd45
commit
c06dd9d999
@ -62,29 +62,30 @@ class InvenTreeObject {
|
|||||||
// TODO - Add "timeout"
|
// TODO - Add "timeout"
|
||||||
// TODO - Add error catching
|
// TODO - Add error catching
|
||||||
|
|
||||||
|
var response = await InvenTreeAPI().get(_URL, params:filters);
|
||||||
|
|
||||||
InvenTreeAPI().get(_URL, params:filters).then((http.Response response) {
|
// A list of "InvenTreeObject" items
|
||||||
|
List<InvenTreeObject> results = new List<InvenTreeObject>();
|
||||||
|
|
||||||
// A list of "InvenTreeObject" items
|
if (response.statusCode != 200) {
|
||||||
List<InvenTreeObject> results = new List<InvenTreeObject>();
|
print("Error retreiving data");
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
final data = json.decode(response.body);
|
final data = json.decode(response.body);
|
||||||
|
|
||||||
for (var d in data) {
|
for (var d in data) {
|
||||||
print(d);
|
print(d);
|
||||||
|
|
||||||
// Create a new object (of the current class type
|
// Create a new object (of the current class type
|
||||||
InvenTreeObject obj = _createFromJson(d);
|
InvenTreeObject obj = _createFromJson(d);
|
||||||
|
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
results.add(obj);
|
results.add(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
return results;
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user