imageProviderStreamWidget function Null safety

BehaviorSubject<ImageProvider<Object>> imageProviderStreamWidget(
  1. {String? imageUrl,
  2. Uint8List? imageMemory,
  3. String? imageAsset,
  4. String? assetPlaceHolder}
)

Implementation

BehaviorSubject<ImageProvider> imageProviderStreamWidget({
  String? imageUrl,
  Uint8List? imageMemory,
  String? imageAsset,
  String? assetPlaceHolder,
}) {
  BehaviorSubject<ImageProvider> stream = BehaviorSubject<ImageProvider>();

  if (imageMemory != null && imageMemory.isNotEmpty) {
    stream.add(MemoryImage(imageMemory));
  } else if (imageUrl != null && imageUrl.isNotEmpty) {
    stream = imageProviderWidgetNetwork(imageUrl);
  } else if (imageAsset != null && imageAsset.isNotEmpty) {
    stream.add(AssetImage(imageAsset));
  } else if (assetPlaceHolder != null && assetPlaceHolder.isNotEmpty) {
    stream.add(AssetImage(assetPlaceHolder));
  }

  return stream;
}