Repo created
This commit is contained in:
parent
2fd78f5dc9
commit
489cf0b2ea
148 changed files with 30898 additions and 2 deletions
22
lib/providers/native_provider.dart
Normal file
22
lib/providers/native_provider.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:android_system_font/android_system_font.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class NativeFeatures {
|
||||
static bool _systemFontLoaded = false;
|
||||
|
||||
static Future<ByteData> _readFileBytes(String path) async {
|
||||
var bytes = await File(path).readAsBytes();
|
||||
return ByteData.view(bytes.buffer);
|
||||
}
|
||||
|
||||
static Future loadSystemFont() async {
|
||||
if (_systemFontLoaded) return;
|
||||
var fontLoader = FontLoader('SystemFont');
|
||||
var fontFilePath = await AndroidSystemFont().getFilePath();
|
||||
fontLoader.addFont(_readFileBytes(fontFilePath!));
|
||||
fontLoader.load();
|
||||
_systemFontLoaded = true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue