'How to prevent the progress indicator to appear again when clicking the selected widget
There are two FilterChips and clicking the selected one will open the progress indicator again. So every time I click on the FilterChip already selected it calls the controller again and the progress indicator returns.
I want nothing to happen when the selected one is clicked but I don't understand the logic.
Also api1Type must be come always true. And loadingController calling progress indicator.
Filter Controller
var filterTypeNumb = 0;
var filterList = [].obs;
RxBool api1Type = true.obs;
RxBool api2Type = false.obs;
void getFilterType() {
if (filterTypeNumb == 0) {
filterList(api1Controller.api1List);
api1Type(true);
api2Type(false);
loadingController2Sec.getLoading();
} else if (filterTypeNumb == 1) {
filterList(api2Controller.api2List);
api1Type(false);
api2Type(true);
loadingController2Sec.getLoading();
}
}
@override
void onInit() {
getFilterType();
super.onInit();
}
}
Filter Chip
FilterTypeController filterTypeController = Get.put(FilterTypeController());
FilterChip(
label: Text(
"Filter 1",
style: fAppNavBarTextStyle,
),
checkmarkColor: Colors.white,
selectedColor: cButtonColor,
backgroundColor: const Color(0xFF878787),
selected:
filterTypeController.api1Type.value,
onSelected: (bool value) {
filterTypeController.filterTypeNumb = 0;
value =
filterTypeController.api1Type.value;
filterTypeController.getFilterType();
//Get.back();
}),
FilterChip(
label: Text(
"Filter 2",
style: fAppNavBarTextStyle,
),
selectedColor: cGetFreeColor,
backgroundColor: const Color(0xFF878787),
selected:
filterTypeController.api2Type.value,
onSelected: (bool value) {
filterTypeController.filterTypeNumb = 1;
value =
filterTypeController.api2Type.value,
filterTypeController.getFilterType();
//Get.back();
}),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
