mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 02:08:56 +03:30
Fix destroy bug in list of items.dart
This commit is contained in:
@@ -202,6 +202,7 @@ class ItemProvider extends ChangeNotifier {
|
|||||||
'Authorization': User.token,
|
'Authorization': User.token,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
print(response.statusCode);
|
||||||
print(response.body);
|
print(response.body);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ class MyItemProvider extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> removeItems(String id) async {
|
||||||
|
myItems!.removeWhere((item) {
|
||||||
|
return item.id.toString() == id;
|
||||||
|
});
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// void searchHospitalItems(String value) {
|
// void searchHospitalItems(String value) {
|
||||||
// hospitalItems = [];
|
// hospitalItems = [];
|
||||||
// searchBoxValue = value;
|
// searchBoxValue = value;
|
||||||
|
|||||||
@@ -537,8 +537,9 @@ class ItemDetailsDataBox extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20.0,
|
height: 20.0,
|
||||||
),
|
),
|
||||||
Consumer<ItemProvider>(
|
Consumer2<ItemProvider, MyItemProvider>(
|
||||||
builder: (context, itemProvider, child) {
|
builder: (context, itemProvider,
|
||||||
|
myItemProvider, child) {
|
||||||
return TransferDestroyButton(
|
return TransferDestroyButton(
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
firstColor: Colors.black,
|
firstColor: Colors.black,
|
||||||
@@ -552,14 +553,13 @@ class ItemDetailsDataBox extends StatelessWidget {
|
|||||||
listen: false)
|
listen: false)
|
||||||
.removeItems(datas.id)
|
.removeItems(datas.id)
|
||||||
.then(
|
.then(
|
||||||
(value) {
|
(value) async {
|
||||||
|
print("11111");
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.pushReplacementNamed(
|
|
||||||
context,
|
|
||||||
Routes.myItemsResultScreen,
|
|
||||||
);
|
|
||||||
itemProvider.resetLoadingButton();
|
itemProvider.resetLoadingButton();
|
||||||
|
myItemProvider
|
||||||
|
.removeItems(datas.id);
|
||||||
Fluttertoast.showToast(
|
Fluttertoast.showToast(
|
||||||
msg: "The item is destroyed.",
|
msg: "The item is destroyed.",
|
||||||
toastLength: Toast.LENGTH_SHORT,
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
@@ -626,26 +626,51 @@ class ItemDetailsDataBox extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20.0,
|
height: 20.0,
|
||||||
),
|
),
|
||||||
TransferDestroyButton(
|
Consumer2<ItemProvider,
|
||||||
deviceBlockSize: _deviceBlockSize,
|
MyItemProvider>(
|
||||||
firstColor: Colors.black,
|
builder: (context, itemProvider,
|
||||||
secondColor: Colors.black87,
|
myItemProvider, child) {
|
||||||
onTap: () {
|
return TransferDestroyButton(
|
||||||
Provider.of<ItemProvider>(context,
|
deviceBlockSize:
|
||||||
listen: false)
|
_deviceBlockSize,
|
||||||
.removeItems(datas.id)
|
firstColor: Colors.black,
|
||||||
.then(
|
secondColor: Colors.black87,
|
||||||
(value) {
|
isLoadingButton: itemProvider
|
||||||
Navigator.of(context).pop();
|
.isloadingButton,
|
||||||
Navigator
|
onTap: () async {
|
||||||
.pushReplacementNamed(
|
itemProvider
|
||||||
context,
|
.setLoadingButton();
|
||||||
Routes.myItemsResultScreen,
|
await Provider.of<
|
||||||
|
ItemProvider>(
|
||||||
|
context,
|
||||||
|
listen: false)
|
||||||
|
.removeItems(datas.id)
|
||||||
|
.then(
|
||||||
|
(value) async {
|
||||||
|
print("22222");
|
||||||
|
Navigator.of(context)
|
||||||
|
.pop();
|
||||||
|
Navigator.of(context)
|
||||||
|
.pop();
|
||||||
|
itemProvider
|
||||||
|
.resetLoadingButton();
|
||||||
|
myItemProvider
|
||||||
|
.removeItems(
|
||||||
|
datas.id);
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg:
|
||||||
|
"The item is destroyed.",
|
||||||
|
toastLength:
|
||||||
|
Toast.LENGTH_SHORT,
|
||||||
|
gravity:
|
||||||
|
ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
text: 'Destroy',
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
text: 'Destroy',
|
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 5.0,
|
height: 5.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user