Refactor flutter to support Android (#1072)

This commit is contained in:
Fangjun Kuang
2024-07-04 10:49:09 +08:00
committed by GitHub
parent 125bb9ff99
commit b502116068
110 changed files with 4547 additions and 32 deletions

View File

@@ -5,14 +5,6 @@ import 'package:path/path.dart' as p;
import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
Future<void> initSherpaOnnx() async {
var uri = await Isolate.resolvePackageUri(
Uri.parse('package:sherpa_onnx/sherpa_onnx.dart'));
if (uri == null) {
print('File not found');
exit(1);
}
String platform = '';
if (Platform.isMacOS) {
@@ -25,6 +17,14 @@ Future<void> initSherpaOnnx() async {
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
}
var uri = await Isolate.resolvePackageUri(
Uri.parse('package:sherpa_onnx_$platform/any_path_is_ok_here.dart'));
if (uri == null) {
print('File not found');
exit(1);
}
final libPath = p.join(p.dirname(p.fromUri(uri)), '..', platform);
sherpa_onnx.initBindings(libPath);
}