boxInList method

dynamic boxInList(
  1. int _r,
  2. int _c,
  3. dynamic _asked,
  4. dynamic _w,
  5. List<String> boxL,
  6. List<String> masterL,
)

box_serve aBox(int _r, _c, _items, _w, List __l) calls this Fill list-box-data in big matrix List, in r, _c coordinates. change to bool!

Implementation

boxInList(
    //  :BUG:DEBUG:  if field-length <_w  => rangeError in called functions.
    int _r,
    int _c,
    _asked,
    _w,
    List<String> boxL,
    List<String> masterL) {
  //  new parameters _asked, _w :  items and asked output width
  if (_w < longestItemInList(boxL)) {
    shortenItemsInList(boxL, _w);
  }

  ///  Only >2 width lists are padded
  if (_w > 2) padListRL(boxL, _w, ' ', ' ');
  int _take = min(boxL.length, _asked); //  All or asked amount.
  //  Take to var, how many items was left out.
  //  Strict type, use:  toInt
  int leftOver = (boxL.length - _asked).toInt(); // count not printed items
  if (leftOver > 0) {
    String _loS = leftOver.toString();
    String _loS2 =
        boxL[_take - 1].substring(0, _w - 7) + ':+:' + _loS; //  nearly _w.
    //  Modify last item in list_
    boxL[_take - 1] = _loS2; //  done: Like:  Item
  }
  for (var x = 0; x < _take; x++) {
    //  Control for range errors
    int itemLength = boxL[x].length;

    int matrixRowLength = masterL[_r].length; // ?

    String _s1 = masterL[_r].substring(0, _c);
    String _s2 = boxL[x]; //  current list value.
    String _s3 = masterL[_r].substring(_c + itemLength, matrixRowLength);
    masterL[_r] = '$_s1$_s2$_s3';
    _r++;
  }
}