linux_webview 0.0.1
linux_webview: ^0.0.1 copied to clipboard
Webview rendering on Linux using GTK
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:ffi' as ffi;
typedef CreateCytoscapeViewNative = ffi.Void Function();
typedef CreateCytoscapeView = void Function();
void showCytoscapeView() {
// Open the dynamic library (ensure the library path is correct)
final dylib = ffi.DynamicLibrary.open('libyourrustcrate.so');
// Look up the 'create_cytoscape_webview' function from the Rust library
final createWebview = dylib
.lookup<ffi.NativeFunction<CreateCytoscapeViewNative>>('create_cytoscape_webview')
.asFunction<CreateCytoscapeView>();
// Call the function to show the WebView
createWebview();
}
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Cytoscape WebView'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
// When the button is pressed, invoke the Rust code to show the WebView
showCytoscapeView();
},
child: Text('Show Cytoscape WebView'),
),
),
),
);
}
}