import 'dart:async'; import 'dart:ffi'; import 'dart:io'; import 'package:ffi/ffi.dart'; import 'package:flutter/services.dart'; typedef HashStuff = Pointer Function(Pointer str); class Argon2Ffi { static const MethodChannel _channel = const MethodChannel('argon2_ffi'); int Function(int x, int y) _nativeAdd; HashStuff _hashStuff; Argon2Ffi() { final argon2lib = Platform.isAndroid ? DynamicLibrary.open('libargon2_ffi.so') : DynamicLibrary.executable(); _nativeAdd = argon2lib .lookup>('native_add') .asFunction(); _hashStuff = argon2lib.lookup>('hashStuff').asFunction(); } int addIt(int x, int y) => _nativeAdd(x, y); String hashStuff(String password) => Utf8.fromUtf8(_hashStuff(Utf8.toUtf8(password))); }