loadImage method

Future<Uint8List?> loadImage()

Tries to download the loading image from the server. Returns image bytes on success, or null if failed.

Implementation

Future<Uint8List?> loadImage() async {
  try {
    final uri = Uri.parse('${config.baseAddress}${config.imagePath}');
    final response = await _httpClient.get(uri).timeout(
      Duration(seconds: config.imageDownloadTimeoutSeconds),
    );
    if (response.statusCode == 200) {
      return response.bodyBytes;
    }
    return null;
  } catch (e) {
    return null;
  }
}