dllimport_gen 1.2.3

Dart native

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.

Example:

import 'package:dllimport_gen/dll_import.dart';

import 'example.ffi.g.dart';

@DllImport('user32.dll')
abstract class User32 {
  /// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setcursorpos
  BOOL SetCursorPos(int X, int Y);
}

@DllImport('kernel32.dll')
abstract class Kernel32 {
  /// https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
  DWORD GetLastError();
}

void main() {
  var user32 = FFIUser32();
  var kernel = FFIKernel32();
  var success = user32.SetCursorPos(0, 0) != 0;
  if (!success) {
    print('Failed: ${kernel.GetLastError()}');
  }
}

Run the code generation: pub run build_runner build

See example/


Use @Import('<library>') to import a custom library in the generated file, if for example you're using your custom structs.

3
likes
70
pub points
2%
popularity

Publisher

hexah.net

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

analyzer, build, source_gen

More

Packages that depend on dllimport_gen