convertBase64ToImage function

Future<Uint8List?> convertBase64ToImage({
  1. required String base64,
})

Implementation

Future<Uint8List?> convertBase64ToImage({required String base64}) async {
  try {
    if (base64.isEmpty) return null;

    final Uint8List imageBytes = base64Decode(base64);

    return imageBytes;
  } catch (e, s) {
    debugPrint('exception while converting image to byte array: ${e.toString()}');
    debugPrint('exception while converting image to byte array: ${s.toString()}');

    return null;
  }
}