buildCheckCell function

Widget buildCheckCell({
  1. String? label,
  2. Color labelColor = Colors.black87,
  3. TextStyle? labelTextStyle,
  4. bool selected = false,
  5. Color selectColor = Colors.blue,
  6. ValueChanged<bool>? onSelected,
  7. EdgeInsets padding = const EdgeInsets.all(5),
})

复选控件

Implementation

Widget buildCheckCell({
  String? label,
  Color labelColor = Colors.black87,
  TextStyle? labelTextStyle,
  bool selected = false,
  Color selectColor = Colors.blue,
  ValueChanged<bool>? onSelected,
  EdgeInsets padding = const EdgeInsets.all(5),
}) {
  return Container(
    alignment: Alignment.centerLeft,
    child: InkWell(
      onTap: () {
        if (onSelected != null) {
          onSelected(!selected);
        }
      },
      child: Container(
        padding: padding,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Icon(selected ? Icons.check_box : Icons.check_box_outline_blank,
                color: selected ? Colors.blue : Colors.black54, size: 18),
            const SizedBox(width: 5),
            Text(
              label ?? '',
              overflow: TextOverflow.ellipsis,
              style:
                  labelTextStyle ?? TextStyle(fontSize: 16, color: labelColor),
            )
          ],
        ),
      ),
    ),
  );
}