import 'package:flutter/material.dart';
import 'package:sendtrain/database/database.dart';

ImageProvider findMediaByType(List<MediaItem> media, MediaType type) {
  Iterable<MediaItem>? found = media.where((m) => m.type == type);
  Image image;

  if (found.isNotEmpty) {
    image = Image.network(found.first.reference);
  } else {
    // Element is not found
    image = Image.asset('assets/images/placeholder.jpg');
  }

  return image.image;
}
