getInRepeatPrefixExp function

String getInRepeatPrefixExp(
  1. dynamic indexName,
  2. dynamic itemName,
  3. dynamic exp,
  4. dynamic inRepeatIndex,
  5. dynamic parentInRepeatPrefixExp
)

获取在for里面的表达前缀,判断父层级是否有前缀,有则需要在拼接在前面 e.g.:var index = 0; var item = listindex; e.g.; var index = 0; var item = listindex; var idx = 0; var it = itemidx;

Implementation

String getInRepeatPrefixExp(
    indexName, itemName, exp, inRepeatIndex, parentInRepeatPrefixExp) {
  var prefix =
      'var $indexName = $inRepeatIndex; var $itemName = $exp[$indexName];';
  if (null != parentInRepeatPrefixExp && parentInRepeatPrefixExp.isNotEmpty) {
    prefix = '$parentInRepeatPrefixExp $prefix';
  }
  return prefix;
}