drydart / flutter_lua

Lua interpreter for Flutter apps.

Home Page:https://pub.dev/packages/flutter_lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flutter Lua Plugin

Project license Pub package Dartdoc reference Travis CI build status Liberapay patrons

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.

About

Lua interpreter for Flutter apps.

https://pub.dev/packages/flutter_lua

License:The Unlicense


Languages

Language:Java 36.7%Language:Dart 30.8%Language:Swift 15.4%Language:Ruby 10.1%Language:Go 4.3%Language:Objective-C 1.7%Language:Lua 0.6%Language:Makefile 0.4%