Skip to main content

flutter_lua_bridge 0.1.0 copy "flutter_lua_bridge: ^0.1.0" to clipboard
flutter_lua_bridge: ^0.1.0 copied to clipboard

Typed Dart / Lua interoperability with annotation-based code generation.

example/example.dart

// Runs Lua from Dart with LuaRuntime. Typed APIs for a whole contract are
// generated by flutter_lua_bridge_codegen; see its example.
import 'package:flutter_lua_bridge/flutter_lua_bridge.dart';

void main() {
  final lua = LuaRuntime.create(); // LuaLibrary.safe by default
  try {
    lua['greet'] = lua.function((args) => 'hello ${args.first}');
    print(lua.eval('return greet("lua")')); // hello lua

    final config =
        lua.eval('return { size = 3, tags = { "a", "b" } }') as LuaTable;
    print(config.toDart()); // {size: 3, tags: [a, b]}

    try {
      lua.eval('error("boom")');
    } on LuaBridgeException catch (e) {
      print(e.message); // (chunk):1: boom
    }
  } finally {
    lua.close();
  }
}
0
likes
0
points
179
downloads

Publisher

verified publishereplab.top

Weekly Downloads

Typed Dart / Lua interoperability with annotation-based code generation.

Repository (GitHub)
View/report issues

Topics

#lua #interop

License

unknown (license)

Dependencies

archive, code_assets, crypto, ffi, flutter_lua_bridge_codegen_annotation, hooks, native_toolchain_c

More

Packages that depend on flutter_lua_bridge