mainScreen method
dynamic
mainScreen(
- dynamic setState
Implementation
mainScreen(setState) {
return Padding(
padding: widget.menuPadding ?? const EdgeInsets.all(0),
child: Container(
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Visibility(
visible:
((widget.showLabelInMenu ?? false) && widget.label != null),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
widget.label.toString(),
style: widget.labelStyle != null
? widget.labelStyle!.copyWith(
color: widget.primaryColor ?? Colors.blue,
)
: TextStyle(
color: widget.primaryColor ?? Colors.blue,
),
),
)),
Visibility(
visible: widget.multiSelect ?? false,
child: Row(
children: [
TextButton(
style: TextButton.styleFrom(
// primary: widget.primaryColor??Colors.black,
tapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: Text(
'Select All',
style: widget.labelStyle != null
? widget.labelStyle!.copyWith(
color: widget.primaryColor ?? Colors.blue,
)
: TextStyle(
color: widget.primaryColor ?? Colors.blue,
),
),
onPressed: () {
selectedValues.clear();
for (int i = 0; i < newDataList.length; i++) {
selectedValues.add(newDataList[i]);
}
setState(() {});
},
),
TextButton(
style: TextButton.styleFrom(
// primary: widget.primaryColor??Colors.black,
tapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: Text(
'Clear All',
style: widget.labelStyle != null
? widget.labelStyle!.copyWith(
color: widget.primaryColor ?? Colors.blue,
)
: TextStyle(
color: widget.primaryColor ?? Colors.blue,
),
),
onPressed: () {
setState(() {
selectedValues.clear();
});
},
),
],
)),
Visibility(
visible: !(widget.menuMode ?? false),
child: searchBox(setState),
),
//
(widget.menuMode ?? false)
? SizedBox(
height: widget.menuHeight ?? 150,
child: mainList(setState),
)
: Expanded(child: mainList(setState)),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
style: TextButton.styleFrom(
// primary: widget.primaryColor??Colors.black,
tapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: Text(
'Close',
style: widget.labelStyle != null
? widget.labelStyle!.copyWith(
color: widget.primaryColor ?? Colors.blue,
)
: TextStyle(
color: widget.primaryColor ?? Colors.blue,
),
),
onPressed: () {
if (widget.menuMode ?? false) {
_menuController.reverse();
} else {
Navigator.pop(context);
}
setState(() {});
},
),
Visibility(
visible: (widget.multiSelect ?? false),
child: TextButton(
style: TextButton.styleFrom(
// primary: widget.primaryColor??Colors.black,
tapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: Text(
'Done',
style: widget.labelStyle != null
? widget.labelStyle!.copyWith(
color: widget.primaryColor ?? Colors.blue,
)
: TextStyle(
color: widget.primaryColor ?? Colors.blue,
),
),
onPressed: () {
var sendList = [];
for (int i = 0; i < menuData.length; i++) {
if (selectedValues.contains(menuData[i])) {
sendList.add(widget.items[i]);
}
}
widget.onChanged(jsonEncode(sendList));
if (widget.menuMode ?? false) {
_menuController.reverse();
} else {
Navigator.pop(context);
}
setState(() {});
},
),
)
],
)
],
),
),
);
}