filterStatusBottomsheet method
dynamic
filterStatusBottomsheet({
- required BuildContext context,
- required List<
String> status, - required dynamic onFilter(),
- required String title,
Implementation
filterStatusBottomsheet(
{required BuildContext context,
required List<String> status,
required final Function(String) onFilter,
required String title}) async {
List<String> userChecked = [];
String selectedStatus = "";
final Localization localization = Localization.getInstance();
showModalBottomSheet(
elevation: 2,
isScrollControlled: true,
context: context,
backgroundColor: ColorConstant.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(SizeConstant.getHeightWithScreen(20)),
topRight: Radius.circular(SizeConstant.getHeightWithScreen(20))),
),
builder: (BuildContext ctx) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Container(
width: double.maxFinite,
decoration: BoxDecoration(
color: ColorConstant.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(
SizeConstant.getHeightWithScreen(20),
),
topRight: Radius.circular(
SizeConstant.getHeightWithScreen(20),
),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(
left: SizeConstant.getHeightWithScreen(15),
right: SizeConstant.getHeightWithScreen(15),
top: SizeConstant.getHeightWithScreen(15),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: TextStyle(
color: ColorConstant.black.withOpacity(0.88),
fontSize: SizeConstant.largeFont,
fontWeight: FontWeight.w600),
),
GestureDetector(
onTap: () {
Get.back();
},
child: Icon(
Icons.close,
color: ColorConstant.grey11,
size: SizeConstant.getHeightWithScreen(27),
),
)
],
),
),
SizedBox(
height: SizeConstant.getHeightWithScreen(36),
),
ListView.builder(
itemCount: status.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return CheckboxListTile(
controlAffinity: ListTileControlAffinity.leading,
activeColor: ColorConstant.primaryColor,
checkColor: ColorConstant.white,
value: userChecked.contains(status[index]),
onChanged: (bool? selected) {
if (selected == true) {
setState(() {
userChecked.clear();
userChecked.add(status[index]);
selectedStatus = status[index];
});
} else {
setState(() {
userChecked.clear();
selectedStatus = "";
});
}
},
title: Text(
status[index],
style: TextStyle(
color: ColorConstant.black.withOpacity(0.88),
fontSize: SizeConstant.mediumFont,
fontWeight: FontWeight.w400,
),
),
);
}),
SizedBox(
height: SizeConstant.getHeightWithScreen(32),
),
Container(
margin: EdgeInsets.symmetric(
horizontal: SizeConstant.getHeightWithScreen(16),
),
child: VentasPrimaryButton(
borderRadius: 9,
btnHeight: 48,
onTap: (selectedStatus.isNotEmpty)
? () {
Get.back();
onFilter(selectedStatus);
}
: null,
label: localization.translate('filter'),
textColor: ColorConstant.white,
textSize: SizeConstant.mediumFont,
weight: FontWeight.w600,
),
),
SizedBox(
height: SizeConstant.getHeightWithScreen(10),
),
],
),
);
});
});
}