cloneRecuriveList method

List cloneRecuriveList({
  1. required List data,
  2. required List<HideRegExp> hideRegExps,
  3. bool ignoreError = false,
})

Implementation

List<dynamic> cloneRecuriveList({
  required List data,
  required List<HideRegExp> hideRegExps,
  bool ignoreError = false,
}) {
  List<dynamic> newData = [];

  for (var index = 0; index < data.length; index++) {
    //
    //
    dynamic loop_data = data[index];
    try {
      if (loop_data is Map || loop_data is List) {
        if (loop_data is Map) {
          newData.add(cloneRecuriveMap(
              data: loop_data,
              hideRegExps: hideRegExps,
              ignoreError: ignoreError));
        } else if (loop_data is List) {
          newData.add(cloneRecuriveList(
              data: loop_data,
              hideRegExps: hideRegExps,
              ignoreError: ignoreError));
        }
      } else if (loop_data is String) {
        newData.add(hideData(
            data: loop_data,
            hideRegExps: hideRegExps,
            ignoreError: ignoreError));
      } else if (loop_data is int) {
        newData.add(int.parse(hideData(
            data: "${loop_data}",
            hideRegExps: hideRegExps,
            ignoreError: ignoreError)));
      } else if (loop_data is double) {
        newData.add(double.parse(hideData(
            data: "${loop_data}",
            hideRegExps: hideRegExps,
            ignoreError: ignoreError)));
      } else if (loop_data is num) {
        newData.add(num.parse(hideData(
            data: "${loop_data}",
            hideRegExps: hideRegExps,
            ignoreError: ignoreError)));
      } else if (loop_data is bool) {
        // skip
        newData.add(loop_data);
      } else {
        // if (loop_data is )
        newData.add(loop_data);
      }
    } catch (e) {
      if (ignoreError) {
        newData.add(loop_data);
      } else {
        rethrow;
      }
    }
  }

  return newData;
}