linux flutter example with bridge to rust and build system

This commit is contained in:
John Smith
2022-01-29 13:23:10 -05:00
parent cbffc381c1
commit 0c6aa6d439
14 changed files with 370 additions and 71 deletions
+14 -17
View File
@@ -8,37 +8,34 @@ import 'dart:html' as html show window;
import 'package:flutter/services.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
// xxx link in WASM version of veilid-flutter
/// A web implementation of the Veilid plugin.
class VeilidWeb {
static void registerWith(Registrar registrar) {
final MethodChannel channel = MethodChannel(
'veilid',
const StandardMethodCodec(),
registrar,
);
// final MethodChannel channel = MethodChannel(
// 'veilid',
// const StandardMethodCodec(),
// registrar,
// );
final pluginInstance = VeilidWeb();
channel.setMethodCallHandler(pluginInstance.handleMethodCall);
// final pluginInstance = VeilidWeb();
// channel.setMethodCallHandler(pluginInstance.handleMethodCall);
}
/// Handles method calls over the MethodChannel of this plugin.
/// Note: Check the "federated" architecture for a new way of doing this:
/// https://flutter.dev/go/federated-plugins
Future<dynamic> handleMethodCall(MethodCall call) async {
switch (call.method) {
case 'getPlatformVersion':
return getPlatformVersion();
default:
// switch (call.method) {
// case 'getPlatformVersion':
// return getPlatformVersion();
// default:
throw PlatformException(
code: 'Unimplemented',
details: 'veilid for web doesn\'t implement \'${call.method}\'',
);
}
// }
}
/// Returns a [String] containing the version of the platform.
Future<String> getPlatformVersion() {
final version = html.window.navigator.userAgent;
return Future.value(version);
}
}