import 'dart:ffi'; import 'dart:io'; class DynamicLibSingleton { static final DynamicLibSingleton _singleton = DynamicLibSingleton._internal(); late DynamicLibrary dl; DynamicLibSingleton._internal() { dl = Platform.isAndroid ? DynamicLibrary.open('libnative_add.so') : DynamicLibrary.process(); } factory DynamicLibSingleton() { return _singleton; } }