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' !");
}
Thanks to you, I came to this:
contains_only(var _list, var e) {
_list.every((element) => element == e);
}
print(contains_only(["Validated", "Draft", "Draft", "Waiting", "Validated"], "Validated"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With