flutter_lua 0.3.0 copy "flutter_lua: ^0.3.0" to clipboard
flutter_lua: ^0.3.0 copied to clipboard

outdated

Lua interpreter and runtime for executing dynamic scripts in Flutter apps.

example/lib/main.dart

/* This is free and unencumbered software released into the public domain. */

import 'dart:async' show Future;

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_lua/flutter_lua.dart' show Lua, LuaThread;

void main() async {
  final version = await Lua.version;
  print("Lua $version");

  final thread = await LuaThread.spawn();
  print(thread);
  print(await thread.eval("return 6*7"));

  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _luaVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String luaVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      luaVersion = await Lua.version;
    } on PlatformException {
      luaVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _luaVersion = luaVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Lua plugin'),
        ),
        body: Center(
          child: Text('Lua $_luaVersion\n'),
        ),
      ),
    );
  }
}
15
likes
30
pub points
13%
popularity

Publisher

unverified uploader

Lua interpreter and runtime for executing dynamic scripts in Flutter apps.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on flutter_lua