getBtnsByText method
Implementation
List<Widget> getBtnsByText() {
List<Widget> result = <Widget>[];
for (int index = 0; index < widget.btnsTxt!.length; ++index) {
String? str = widget.btnsTxt![index];
result.add(Container(
padding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(getButtonColor(index)),
overlayColor: MaterialStateProperty.all(Colors.transparent),
padding: MaterialStateProperty.all(const EdgeInsets.all(10)),
),
child: Text(
str,
style: TextStyle(
color: getBtnTextColor(index),
fontSize: BaseFonts.f12,
),
),
onPressed: () {
if (!widget.isEdit ||
(widget.enableBtnList != null &&
!widget.enableBtnList![index])) {
return;
}
if (widget.onBtnSelectChanged != null) {
widget.onBtnSelectChanged!(index);
}
if (_useInnerStatus) {
// 如果是内部维护的状态,需要改变按钮的状态
widget.selectBtnList![index] =
widget.selectBtnList![index] ? false : true;
}
setState(() {});
/*
List<bool> previewSelectedBtnIndex = List<bool>();
for (int pos = 0; pos < widget.selectBtnList.length; ++pos) {
previewSelectedBtnIndex.add(widget.selectBtnList[pos]);
}
widget.selectBtnList[index] = widget.selectBtnList[index] ? false : true;
setState(() {});
if (widget.onBtnSelectChanged != null) {
widget.onBtnSelectChanged(previewSelectedBtnIndex, widget.selectBtnList);
}
*/
},
),
));
}
return result;
}