imageProviderFromAsset method Null safety

ImageProvider<Object>? imageProviderFromAsset(
  1. String url
)

Returns an AssetImage.

Implementation

ImageProvider? imageProviderFromAsset(String url) {
  final uri = Uri.parse(url);
  final assetName = uri.path;
  if (assetName.isEmpty) {
    return null;
  }

  final package = uri.queryParameters.containsKey('package') == true
      ? uri.queryParameters['package']
      : null;

  return AssetImage(assetName, package: package);
}