loadFromFile static method

void loadFromFile(
  1. String family,
  2. String filePath, {
  3. FontWeight weight = FontWeight.normal,
  4. FontStyle style = FontStyle.normal,
})

Registers a font from a file path.

Reads the file synchronously. Throws if the file does not exist or is not a valid font file.

Implementation

static void loadFromFile(
  String family,
  String filePath, {
  FontWeight weight = FontWeight.normal,
  FontStyle style = FontStyle.normal,
}) {
  final bytes = File(filePath).readAsBytesSync();
  load(family, bytes, weight: weight, style: style);
}