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) {
2024-05-02 14:15:42 -04:00
const platformConfig = VeilidWASMConfig(
2022-12-10 12:11:46 -05:00
logging: VeilidWASMConfigLogging(
performance: VeilidWASMConfigLoggingPerformance(
enabled: true,
level: VeilidConfigLogLevel.debug,
logsInTimings: true,
logsInConsole: true),
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 {
2024-05-02 14:15:42 -04:00
const platformConfig = 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,
2024-05-02 14:15:42 -04:00
grpcEndpoint: 'localhost:4317',
serviceName: 'VeilidExample'),
2022-12-10 12:11:46 -05:00
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
}
}