To create a set of strings in Dart, you can use the Set class.
In this example,
stringSet
to store strings.void main() {
Set<String> stringSet = Set<String>();
stringSet.add("Apple");
stringSet.add("Banana");
stringSet.add("Orange");
stringSet.add("Grapes");
print("Set of strings: $stringSet");
}
Set of strings: {Apple, Banana, Orange, Grapes}
In this example,
void main() {
var stringSet = <String>{"Apple", "Banana", "Orange", "Grapes"};
print("Set of strings: $stringSet");
}
Set of strings: {Apple, Banana, Orange, Grapes}
In this tutorial, we learned How to create a Set of Strings in Dart language with well detailed examples.