The Iterable Collection docs state the following:
In Dart, an
Iterableis an abstract class, meaning that you can’t instantiate it directly. However, you can create a newIterableby creating a newListorSet.
That makes sense to me. But then I realized, "Wait, List and Set are also abstract." List source code:
abstract class List<E> implements EfficientLengthIterable<E> {
How is it that the Dart analyzer knows I can't do this:
final myIterable = Iterable();
But I can do this:
Iterable<String> myIterable = List<String>.empty();
Is it because Dart follows the exteral factory to some concrete implementation somewhere? List source code:
external factory List.empty({bool growable = false});
I'm trying to understand abstract and concrete classes and how the Dart analyzer knows what error message to give me.