downloadFontBytes method

Future<Uint8List?> downloadFontBytes({
  1. required String url,
})

Downloads the bytes of a font from the server given a url.

Implementation

Future<Uint8List?> downloadFontBytes({required String url}) async {
  try {
    final http.Response response = await http.get(Uri.parse(url));
    if (response.statusCode != 200) return null;

    return Uint8List.view(response.bodyBytes.buffer);
  } catch (e, str) {
    logger.error(
      _label,
      'Error downloading font bytes',
      error: e,
      stackTrace: str,
    );
    return null;
  }
}