linux flutter example with bridge to rust and build system
This commit is contained in:
@@ -1,13 +1,38 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:veilid/bridge_generated.dart';
|
||||
|
||||
class Veilid {
|
||||
static const MethodChannel _channel = MethodChannel('veilid');
|
||||
const base = 'veilid_flutter';
|
||||
final path = Platform.isWindows
|
||||
? '$base.dll'
|
||||
: Platform.isMacOS
|
||||
? 'lib$base.dylib'
|
||||
: 'lib$base.so';
|
||||
late final dylib = Platform.isIOS ? DynamicLibrary.process() : DynamicLibrary.open(path);
|
||||
late final veilidApi = VeilidFlutterImpl(dylib);
|
||||
|
||||
static Future<String?> get platformVersion async {
|
||||
final String? version = await _channel.invokeMethod('getPlatformVersion');
|
||||
return version;
|
||||
class Veilid {
|
||||
|
||||
static VeilidFlutterImpl get api {
|
||||
if (veilidApi == null) {
|
||||
throw PlatformException(
|
||||
code: 'Library missing',
|
||||
details: 'veilid_core library could not be loaded dynamically',
|
||||
);
|
||||
}
|
||||
return veilidApi;
|
||||
}
|
||||
|
||||
// static const MethodChannel _channel = MethodChannel('veilid');
|
||||
|
||||
// static Future<String?> get platformVersion async {
|
||||
// final String? version = await _channel.invokeMethod('getPlatformVersion');
|
||||
// return version;
|
||||
// }
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user