effortTable function

List<String> effortTable(
  1. List<Map<String, String>> _ilM,
  2. String _sf,
  3. int _w,
  4. dynamic _itemC,
)

Gets some small data from effortLM based on parameters.

Implementation

List<String> effortTable(
    List<Map<String, String>> _ilM, String _sf, int _w, _itemC) {
  //  _sf  String, that swe are looking for, like: E:5  or  M:7
  //  _w  how wide String of map-key we want?
  //  _itemC  how many values we want?
  //  _ilM  is effortLM
  //  print('parameters:: _sf::  $_sf  _w:: $_w   _itemC::  $_itemC ');

  String _foundS = '';
  List<String> _l = [];

  //  Handle whole list.
  for (var x = 0; x < _ilM.length; x++) {
    // 'Seek every map for search-criteria'
    for (var y in _ilM[x].keys) {
      //  Zero / short length check. Is it needed?
      //  howTo NULL
      if (_ilM[x][y]!.length < 2) {
        print('ALERT::    _ilM[x][y].length < 2   ********************');
      }
      ;

      //  Found String?
      //  analysis, rep 2 hints:  l-188 c-12: Use contains instead of indexOf
      //  Old way:  if ((_ilM[x][y].indexOf(_sf) > -1)) {
      //  New way using #contains:
      //  howTo NULL ok
      if ((_ilM[x][y]!).contains(_sf)) {
        ///  separating index finding.
        int iSub = _ilM[x][y]!.indexOf(_sf);
        //  Are we over right edge of list.item?
        if ((iSub + 3) >= _ilM[x][y]!.length) {
          print('ALERT:: iSub +3  >  _ilM[x][y].length   **************');
        }
        ;

        //  TODO  check for: not to be out of range.
        //  print(_ilM[x][y].substring(iSub ,iSub+3));
        _foundS = _ilM[x][y]!.substring(iSub, iSub + 3);

        ///  Drive String manipulation in order, for to be sure.
        ///  Surely shorter way might exist.
        String tempS1 = y; //  key
        String tempS2 = tempS1; //

        //  TODO  force all items to tl.longestItemInList, or...
        //  force Strings to width:  _w
        if (tempS1.length < _w + 2) {
          tempS2 = tempS1.padRight(_w, ' ');
          //  force all to same length
        } else {
          tempS2 = tempS1.substring(0, _w);
        }
        String tempS3 = tempS2 + ' ' + _foundS;
        //  Or temp2S is as it was.
        _l.add(tempS3);
      }
    }
  }
  List<String> sL = [];
  //  TODO  check for int 1-9
  //  Add to sL in numeric-high order

  for (var x = 9; x > -1; x--) {
    String sx = x.toString();
    for (var y in _l) {
      //  analysis, rep 2 hints:  l-228 c-11: Use contains instead of indexOf
      //  Old way:  if (y.indexOf(sx) > -1) {
      //  New way using #contains:
      if (y.contains(sx)) {
        sL.add(y);
      }
    }
  }
  List<String> _retL = [];
  _retL.addAll(sL.take(_itemC));
  print(_retL);
  print('------------------------ effortTable done-----------------------');
  return _retL;
}