dynamic_lib_singleton.dart 392 B

1234567891011121314151617
  1. import 'dart:ffi';
  2. import 'dart:io';
  3. class DynamicLibSingleton {
  4. static final DynamicLibSingleton _singleton = DynamicLibSingleton._internal();
  5. late DynamicLibrary dl;
  6. DynamicLibSingleton._internal() {
  7. dl = Platform.isAndroid
  8. ? DynamicLibrary.open('libnative_add.so')
  9. : DynamicLibrary.process();
  10. }
  11. factory DynamicLibSingleton() {
  12. return _singleton;
  13. }
  14. }