dataToOrigin<T> static method
T
dataToOrigin<T>({
- required T data,
- required List<
HideRegExp> hideRegExps, - bool ignoreError = false,
Implementation
static T dataToOrigin<T>({
required T data,
required List<HideRegExp> hideRegExps,
bool ignoreError = false,
}) {
Hide hide = Hide();
try {
if (data is Map || data is List) {
if (data is Map) {
return hide.cloneRecuriveMap(
data: data,
hideRegExps: hideRegExps,
ignoreError: ignoreError) as T;
} else if (data is List) {
return hide.cloneRecuriveList(
data: data,
hideRegExps: hideRegExps,
ignoreError: ignoreError) as T;
}
}
if (data is String) {
return (hide.hideData(
data: data,
hideRegExps: hideRegExps,
ignoreError: ignoreError) as T);
}
if (data is int) {
return int.parse(hide.hideData(
data: "${data}",
hideRegExps: hideRegExps,
ignoreError: ignoreError)) as T;
} else if (data is double) {
return double.parse(hide.hideData(
data: "${data}",
hideRegExps: hideRegExps,
ignoreError: ignoreError)) as T;
} else if (data is num) {
return num.parse(hide.hideData(
data: "${data}",
hideRegExps: hideRegExps,
ignoreError: ignoreError)) as T;
} else if (data is bool) {
return data;
}
return (hide.hideData(
data: data.toString(),
hideRegExps: hideRegExps,
ignoreError: ignoreError)) as T;
} catch (e) {
if (ignoreError) {
return data;
} else {
rethrow;
}
}
}