veilid/veilid-flutter/example/lib/veilid_init.dart

35 lines
1.3 KiB
Dart
Raw Normal View History

2022-12-10 12:11:46 -05:00
import 'package:flutter/foundation.dart';
import 'package:veilid/veilid.dart';
// Initialize Veilid
// Call only once.
void veilidInit() {
if (kIsWeb) {
2023-07-06 12:06:50 -04:00
var platformConfig = const VeilidWASMConfig(
2022-12-10 12:11:46 -05:00
logging: VeilidWASMConfigLogging(
performance: VeilidWASMConfigLoggingPerformance(
enabled: true,
level: VeilidConfigLogLevel.debug,
logsInTimings: true,
2022-12-10 19:11:58 -05:00
logsInConsole: false),
2022-12-10 12:11:46 -05:00
api: VeilidWASMConfigLoggingApi(
enabled: true, level: VeilidConfigLogLevel.info)));
2023-05-29 15:24:57 -04:00
Veilid.instance.initializeVeilidCore(platformConfig.toJson());
2022-12-10 12:11:46 -05:00
} else {
2023-07-06 12:06:50 -04:00
var platformConfig = const VeilidFFIConfig(
2022-12-10 12:11:46 -05:00
logging: VeilidFFIConfigLogging(
terminal: VeilidFFIConfigLoggingTerminal(
enabled: false,
level: VeilidConfigLogLevel.debug,
),
otlp: VeilidFFIConfigLoggingOtlp(
enabled: false,
level: VeilidConfigLogLevel.trace,
grpcEndpoint: "localhost:4317",
serviceName: "VeilidExample"),
api: VeilidFFIConfigLoggingApi(
enabled: true, level: VeilidConfigLogLevel.info)));
2023-05-29 15:24:57 -04:00
Veilid.instance.initializeVeilidCore(platformConfig.toJson());
2022-12-10 12:11:46 -05:00
}
}