Fix null items in add package

This commit is contained in:
fhkhd
2024-01-22 21:33:32 +03:30
parent 9b677ac7d4
commit 2de3537db5
+20 -25
View File
@@ -129,6 +129,7 @@ class PackageProvider extends ChangeNotifier {
),
);
}
if (result.isEmpty) result.add("");
itemVals = result;
initialItemValue = itemVals[0];
TextEditingController newLbl = new TextEditingController();
@@ -248,24 +249,22 @@ class PackageProvider extends ChangeNotifier {
items = [];
searchBoxValue = value;
originalItems!.forEach((result) {
if (
result.id
.toString()
.toLowerCase()
.contains(searchBoxValue.toLowerCase()) ||
result.id
.toString()
.toUpperCase()
.contains(searchBoxValue.toUpperCase()) ||
result.id
.toString()
.toLowerCase()
.contains(searchBoxValue.toUpperCase()) ||
result.id
.toString()
.toUpperCase()
.contains(searchBoxValue.toLowerCase())
) {
if (result.id
.toString()
.toLowerCase()
.contains(searchBoxValue.toLowerCase()) ||
result.id
.toString()
.toUpperCase()
.contains(searchBoxValue.toUpperCase()) ||
result.id
.toString()
.toLowerCase()
.contains(searchBoxValue.toUpperCase()) ||
result.id
.toString()
.toUpperCase()
.contains(searchBoxValue.toLowerCase())) {
items!.add(result);
}
});
@@ -334,12 +333,11 @@ class PackageProvider extends ChangeNotifier {
}
var data = json.decode(response.body)['data'];
List<String> itemsList = [];
if(data['items'] != null){
if (data['items'] != null) {
for (var item in data['items']) {
// itemsList
// .add("${item['name']} - ${item['udi'] != null ? item['udi'] : ''}");
itemsList
.add("${item['id']} ${item['name']}");
itemsList.add("${item['id']} ${item['name']}");
}
}
print(data);
@@ -362,10 +360,7 @@ class PackageProvider extends ChangeNotifier {
final baseStorage = await getExternalStorageDirectory();
final taskId = await FlutterDownloader.enqueue(
url: Url.exportPackages,
headers: {
'Authorization': User.token,
"Accept": "*"
},
headers: {'Authorization': User.token, "Accept": "*"},
savedDir: baseStorage!.path,
showNotification: true,
openFileFromNotification: true,