1234567891011121314151617181920212223242526 |
- import 'dart:convert';
- import 'dart:io';
- import 'package:image_picker/image_picker.dart';
- import 'package:uuid/uuid.dart';
- import 'package:fis_common/logger/logger.dart';
- abstract class UploadUtils {
- static XFile? convertBase64ToXFile(String base64Stirng) {
- try {
- final bytes = base64Decode(base64Stirng);
- final tempDir = Directory.systemTemp;
- final tempPath = tempDir.path;
- final imageId = const Uuid().v4().replaceAll('-', '');
- final filePath = '$tempPath/$imageId';
- File(filePath).writeAsBytesSync(bytes);
- return XFile(filePath);
- } catch (e) {
- print('Error converting base64 to XFile: $e');
- logger.i('Error converting base64 to XFile: $e');
- return null;
- }
- }
- }
|