initializeGhosttyVteWeb function
- String assetPath = 'packages/ghostty_vte_flutter/assets/ghostty-vt.wasm',
Package-level setup and lightweight terminal widgets for Flutter.
The wasm runtime can be initialized via initializeGhosttyVteWeb on web before constructing web terminal views. Initializes the Ghostty wasm module on web from bundled Flutter assets.
Call this early in your main() before constructing any terminal views
on web targets. This is a no-op on native platforms.
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeGhosttyVteWeb();
runApp(const MyApp());
}
Implementation
/// Initializes the Ghostty wasm module on web from bundled Flutter assets.
///
/// Call this early in your `main()` before constructing any terminal views
/// on web targets. This is a no-op on native platforms.
///
/// ```dart
/// void main() async {
/// WidgetsFlutterBinding.ensureInitialized();
/// await initializeGhosttyVteWeb();
/// runApp(const MyApp());
/// }
/// ```
Future<void> initializeGhosttyVteWeb({
String assetPath = 'packages/ghostty_vte_flutter/assets/ghostty-vt.wasm',
}) async {
if (!kIsWeb || GhosttyVtWasm.isInitialized) {
return;
}
final data = await rootBundle.load(assetPath);
await GhosttyVtWasm.initializeFromBytes(
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes),
);
}