imageUrlToFile method

  1. @override
Future<File?> imageUrlToFile(
  1. String imageUrl,
  2. String fullLocalName
)
override

Implementation

@override
Future<File?> imageUrlToFile(String imageUrl, String fullLocalName) async {
  try {
    final response = await http.get(Uri.parse(imageUrl));

    if (response.statusCode == 200) {
      Uint8List bytes = response.bodyBytes;

      File file = File(fullLocalName);
      return await file.writeAsBytes(bytes);
    } else {
      // Error al obtener la imagen
      return null;
    }
  } catch (e) {
    // Error general
    return null;
  }
}