flutter_lua 0.3.1

Flutter Lua Plugin #

Project license Pub package Dartdoc reference Travis CI build status

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.

Changelog #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

0.3.1 - 2019-04-24

Changed #

  • Improved the example app

0.3.0 - 2019-03-14

Added #

  • Added initial iOS platform support (#1)
  • Lua.eval() static method
  • Lua.evalAsset() static method
  • Lua.evalFile() static method

Removed #

  • Lua.doString() method (use Lua.eval())
  • Lua.doFile() method (use Lua.evalFile())

0.2.0 - 2019-03-10

Added #

  • LuaError exception class

Changed #

  • Implemented PlatformException wrapping

0.1.0 - 2019-02-27

Added #

  • Lua.version static getter
  • LuaThread#eval() method
  • LuaThread#evalAsset() method
  • LuaThread#evalFile() method
  • LuaThread#exec() method
  • LuaThread#execAsset() method
  • LuaThread#execFile() method


flutter_lua_example #

Demonstrates how to use the flutter_lua plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_lua: ^0.3.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_lua/flutter_lua.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 18, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
meta ^1.1.6 1.1.8
Transitive dependencies
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
test any