Skip to content

Instantly share code, notes, and snippets.

@steph-crown
Created October 16, 2020 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steph-crown/384d3658df6c070139fb3b722243340a to your computer and use it in GitHub Desktop.
Save steph-crown/384d3658df6c070139fb3b722243340a to your computer and use it in GitHub Desktop.
Checks if a list is a subset of another list
///A function that checks if a list is a subset of another
bool subsetChecker(List list1, List list2) {
//Iterates through first array and checks if all element are in second array
return list1.every((item) => list2.contains(item));
}
void main() {
print(subsetChecker([1,2,3], [1,2,4,3,5]));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment