Created
March 3, 2020 06:08
-
-
Save RaguRam1991/b4a89742f986735266da6b7f4ec20ef3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = []; | |
var arr1; | |
var crit = {"prsn": "", "age": 20, "color": ""}; | |
void main() { | |
for (int i = 0; i < 3; i++) { | |
arr.add({"prsn": "name${i + 1}", "age": 25 + i, "color": "green"}); | |
//arr[i]=i+1; | |
} | |
arr[1]['color'] = "yellow"; | |
arr[2]['color'] = "red"; | |
arr.add({"prsn": "name1", "age": 20, "color": "blue"}); | |
arr.add({"prsn": "name5", "age": 25, "color": "green"}); | |
print("actual array\n$arr"); | |
arr1 = arr; | |
if (crit["prsn"] != null && crit["prsn"].toString().length > 0) | |
arr1 = arr1.where((ele) => ele["prsn"] == crit["prsn"]); | |
if (crit["age"] != null) | |
arr1 = arr1.where((ele) => ele["age"] == crit["age"]); | |
if (crit["color"] != null && crit["color"].toString().length > 0) | |
arr1 = arr1.where((ele) => ele["color"] == crit["color"]); | |
print("\nfiltered array\n$arr1"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment