I have a question about NetworkImage of Flutter.
CircleAvatar(
backgroundImage: NetworkImage(''),
),
backgroundImage of CircleAvatar accept ImageProvider type. But ImageProvider class is an abstract class, so other subtype like AssetImage, FileImage, NetworkImage class object can be assigned to backgroundImage. That code doesn't have any problem.
abstract class NetworkImage extends ImageProvider<NetworkImage> {
const factory NetworkImage(String url, { double scale, Map<String, String>? headers }) = network_image.NetworkImage;
String get url;
double get scale;
Map<String, String>? get headers;
@override
ImageStreamCompleter load(NetworkImage key, DecoderCallback decode);
@override
ImageStreamCompleter loadBuffer(NetworkImage key, DecoderBufferCallback decode);
}
Here is my question. NetworkImage class is also an abstract class. I have learned that abstract class can't be instantiated, but NetworkImage can be instantiated although it is an abstract class.
How can it be done?
ImageProvider() can't be assigned to the backgroundImage because it's an abstract class so it can't be instantiated.