loadBackgroundImage method
Future<void>
loadBackgroundImage(
- XFile backgroundImage
)
Implementation
Future<void> loadBackgroundImage(XFile backgroundImage) async {
try {
_isLoading = true;
notifyListeners();
final imageFile = File(backgroundImage.path);
final bytes = await imageFile.readAsBytes();
final codec = await ui.instantiateImageCodec(bytes);
final frame = await codec.getNextFrame();
_backgroundImageUI = frame.image;
_imageWidth = frame.image.width.toDouble();
_imageHeight = frame.image.height.toDouble();
_isLoading = false;
notifyListeners();
} catch (e) {
debugPrint('Error loading background image: $e');
_isLoading = false;
notifyListeners();
}
}