flutter_lualike 0.1.0
flutter_lualike: ^0.1.0 copied to clipboard
Flutter AssetBundle filesystem backend for lualike. Provides transparent read-only file access for dofile(), require(), io.open(), and module loading from Flutter assets. Includes a composite backend [...]
flutter_lualike #
Flutter AssetBundle
filesystem backend for lualike. Provides
transparent read-only file access for dofile() and module loading from Flutter
assets.
Install #
dependencies:
flutter_lualike: ^0.1.0
lualike: ^0.3.0
Then run:
flutter pub get
Usage #
import 'package:flutter_lualike/flutter_lualike.dart';
await useAssetBundle(rootBundle, assetRoot: 'assets');
// Now dofile('config.lua') resolves to assets/config.lua
Desktop (local filesystem fallback) #
import 'package:file/local.dart';
import 'package:file_lualike/file_lualike.dart';
import 'package:flutter_lualike/flutter_lualike.dart';
import 'package:lualike/lualike.dart';
final backend = CompositeFileSystemBackend([
AssetBundleFileSystemBackend(rootBundle, assetRoot: 'assets'),
PackageFileSystemBackend(LocalFileSystem()),
]);
setFileSystemBackend(backend);
How it works #
Two integration points are wired when you call useAssetBundle():
-
FileSystemProvider—io.open()createsAssetBundleIODeviceinstances that read from the bundle (read-only, mode"r"only). -
FileSystemBackend—dofile(),require(),os.remove()and other metadata operations delegate toAssetBundleFileSystemBackend, which resolves paths via the asset manifest.
Components #
| Class | Purpose |
|---|---|
AssetBundleFileSystemBackend |
FileSystemBackend backed by AssetBundle + AssetManifest |
AssetBundleIODevice |
Read-only IODevice for io.open() |
useAssetBundle() |
One-call setup for both integration points |
For writable storage, combine with CompositeFileSystemBackend from core lualike
and PackageFileSystemBackend from file_lualike.