I need to know if there are only string equals to "Validated" in the list, how can I check it in 1 line of code ? (If the list is empty, I already checked the condition before so this particular case isn't important).
List<String> state_str_list = ["Validated", "Draft", "Draft", "Waiting", "Validated"];
if (???) {
print("all values in state_str_list are equals to 'Validated' !");
}
List.everymethod - the docs say: "Checks whether every element of this iterable satisfies test. Checks every element in iteration order, and returns false if any of them make test return false, otherwise returns true."list.containsmethod likestate_str_list.contains("value");List<String> state_str_list = ["Validated", "Draft", "Draft", "Waiting", "Validated"].where((element) => element.contains("Validated")).toList();true/falseboolean, not a list - this is whereList.everyshould be used, notList.wherevar d = ["Validated", "Draft", "Draft", "Waiting", "Validated"] .contains("Validated");