plusMinus function

dynamic plusMinus(
  1. String id,
  2. int count,
  3. dynamic callback(
    1. String id,
    2. int count
    ), {
  4. bool countMayBeNull = false,
  5. double padding = 3,
})

Implementation

plusMinus(String id, int count,
  Function(String id, int count) callback, {bool countMayBeNull = false, double padding = 3}) {
  // dprint("plusMinus item.count=$count $id");
  var _color = count > 1 ? aTheme.mainColor : Colors.grey;
  if (countMayBeNull)
    _color = aTheme.mainColor;
  return Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      InkWell(
        onTap: () {
          if (count > 1)
            count--;
          else
          if (countMayBeNull && count == 1)
            count--;
          callback(id, count);
        },
        child: Container(
        padding: EdgeInsets.all(padding),
        decoration: BoxDecoration(
          color: _color,
          shape: BoxShape.circle,
        ),
        child: Icon(Icons.exposure_minus_1, size: 15, color: Colors.white,)),
      ),
      SizedBox(width: 5,),
      Text(count.toString(), style: aTheme.style14W800),
      SizedBox(width: 5,),
      InkWell(
        onTap: () {
          count++;
          // dprint("plusMinus item.count++=$count $id");
          callback(id, count);
        },
        child: Container(
        padding: EdgeInsets.all(padding),
        decoration: BoxDecoration(
          color: aTheme.mainColor,
          shape: BoxShape.circle,
        ),
        child: Icon(Icons.plus_one, size: 15, color: Colors.white,)),
      ),
    ],
  );
}