Flutter Lua Plugin
This is a Flutter plugin that embeds a Lua interpreter and runtime for executing dynamic scripts from Flutter apps.
Features
-
Embeds a Lua 5.2 interpreter into your Flutter app.
-
Executes Lua code on a background thread (not on the main UI thread).
-
Supports executing source code snippets from strings as well as from source files bundled in your app's asset bundle.
Compatibility
Android and iOS both.
Examples
Checking the Lua runtime version
import 'package:flutter_lua/flutter_lua.dart' show Lua;
print(await Lua.version);
Spawning a new Lua interpreter thread
import 'package:flutter_lua/flutter_lua.dart' show LuaThread;
var thread = await LuaThread.spawn();
Evaluating a Lua code snippet
import 'package:flutter_lua/flutter_lua.dart' show LuaThread;
var thread = await LuaThread.spawn();
await thread.eval("return 6 * 7"); //=> 42.0
Executing a bundled Lua source file
import 'package:flutter_lua/flutter_lua.dart' show LuaThread;
var thread = await LuaThread.spawn();
await thread.execAsset("scripts/myscript.lua");
Frequently Asked Questions
How much does using this plugin increase my final app size?
About 3.8 MiB, at present.
Caveats
- Currently the only supported result datatypes from
LuaThread#eval*()
methods are booleans, floating-point numbers (doubles), and strings. This will be extended further over the next releases.
Libraries
- flutter_lua
- Lua interpreter for Flutter.