mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
29 lines
760 B
Dart
29 lines
760 B
Dart
import 'dart:io';
|
|
import 'dart:ffi';
|
|
import 'package:ffi/ffi.dart';
|
|
|
|
const String _libName = 'esotericsoftware_spine_flutter';
|
|
final DynamicLibrary _dylib = () {
|
|
if (Platform.isMacOS || Platform.isIOS) {
|
|
return DynamicLibrary.open('$_libName.framework/$_libName');
|
|
}
|
|
if (Platform.isAndroid || Platform.isLinux) {
|
|
return DynamicLibrary.open('lib$_libName.so');
|
|
}
|
|
if (Platform.isWindows) {
|
|
return DynamicLibrary.open('$_libName.dll');
|
|
}
|
|
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
|
|
}();
|
|
|
|
class SpineFlutterFFI {
|
|
DynamicLibrary dylib;
|
|
Allocator allocator;
|
|
|
|
SpineFlutterFFI(this.dylib, this.allocator);
|
|
}
|
|
|
|
Future<SpineFlutterFFI> initSpineFlutterFFI() async {
|
|
return SpineFlutterFFI(_dylib, malloc);
|
|
}
|