adding packages

This commit is contained in:
2026-01-15 14:38:46 -08:00
parent ef86e3ab6a
commit 6869cf47e5
5253 changed files with 726695 additions and 34 deletions
@@ -0,0 +1,5 @@
library flutter_wasm_interop;
export 'src/unsupported.dart'
if (dart.library.html) 'src/web.dart'
if (dart.library.io) 'src/io.dart';
@@ -0,0 +1,7 @@
abstract class WasmImpl {
WasmImpl.fromAssets(String path);
Future<bool> init();
bool get isReady;
Future function(String name);
Future functionParam(String name, dynamic input);
}
@@ -0,0 +1,27 @@
import 'impl.dart';
class WasmLoader extends WasmImpl {
@override
Future function(String name) {
// TODO: implement function
throw UnimplementedError();
}
@override
Future functionParam(String name, input) {
// TODO: implement functionParam
throw UnimplementedError();
}
@override
// TODO: implement isReady
bool get isReady => throw UnimplementedError();
WasmLoader.fromAssets(String path) : super.fromAssets(path);
@override
Future<bool> init() {
// TODO: implement init
throw UnimplementedError();
}
}
@@ -0,0 +1,27 @@
import 'impl.dart';
class WasmLoader extends WasmImpl {
@override
Future function(String name) {
// TODO: implement function
throw UnimplementedError();
}
@override
Future functionParam(String name, input) {
// TODO: implement functionParam
throw UnimplementedError();
}
@override
// TODO: implement isReady
bool get isReady => throw UnimplementedError();
WasmLoader.fromAssets(String path) : super.fromAssets(path);
@override
Future<bool> init() {
// TODO: implement init
throw UnimplementedError();
}
}
@@ -0,0 +1,40 @@
// Import dart:ffi.
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:wasm_interop/wasm_interop.dart';
import 'impl.dart';
class WasmLoader extends WasmImpl {
Instance _wasm;
String _path;
WasmLoader.fromAssets(String path)
: _path = path,
super.fromAssets(path);
@override
Future function(String name) {
final _func = _wasm.functions[name];
final _result = _func.call();
return _result;
}
@override
Future functionParam(String name, input) {
final _func = _wasm.functions[name];
final _result = _func.call(input);
return _result;
}
@override
bool get isReady => _wasm != null;
@override
Future<bool> init() async {
assert(_path != null);
final _data = await rootBundle.load(_path);
_wasm = await Instance.fromBufferAsync(_data.buffer);
return isReady;
}
}