importFont method

Future<String> importFont(
  1. String fontName
)

Implementation

Future<String> importFont(String fontName) async {
  final tempDir = await getTemporaryDirectory();
  final ByteData assetByteData =
      await rootBundle.load('packages/gify/assets/fonts/$fontName');

  final List<int> byteList = assetByteData.buffer
      .asUint8List(assetByteData.offsetInBytes, assetByteData.lengthInBytes);

  final String fullTemporaryPath = '${tempDir.path}/$fontName';

  await File(fullTemporaryPath)
      .writeAsBytes(byteList, mode: FileMode.writeOnly, flush: true);
  return fullTemporaryPath;
}