2023-01-11 19:17:04 -05:00
|
|
|
import 'dart:async';
|
2023-07-26 14:20:29 -04:00
|
|
|
import 'dart:io';
|
2023-01-11 19:17:04 -05:00
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
2023-01-07 21:43:31 -05:00
|
|
|
import 'package:flutter/material.dart';
|
2023-01-08 22:27:33 -05:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2023-07-22 23:29:10 -04:00
|
|
|
import 'package:flutter_translate/flutter_translate.dart';
|
|
|
|
|
2023-07-26 14:20:29 -04:00
|
|
|
import 'app.dart';
|
2023-01-11 19:17:04 -05:00
|
|
|
import 'log/log.dart';
|
2023-07-28 20:36:05 -04:00
|
|
|
import 'providers/window_control.dart';
|
|
|
|
import 'tools/theme_service.dart';
|
2023-07-26 14:20:29 -04:00
|
|
|
import 'veilid_support/veilid_support.dart';
|
2023-07-23 23:13:21 -04:00
|
|
|
|
2023-01-08 22:27:33 -05:00
|
|
|
void main() async {
|
2023-01-11 19:17:04 -05:00
|
|
|
// Disable all debugprints in release mode
|
|
|
|
if (kReleaseMode) {
|
2023-07-26 14:20:29 -04:00
|
|
|
debugPrint = (message, {wrapWidth}) {};
|
2023-01-11 19:17:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print our PID for debugging
|
|
|
|
if (!kIsWeb) {
|
|
|
|
debugPrint('VeilidChat PID: $pid');
|
|
|
|
}
|
|
|
|
|
2023-01-08 22:27:33 -05:00
|
|
|
// Logs
|
|
|
|
initLoggy();
|
|
|
|
|
2023-01-11 19:17:04 -05:00
|
|
|
// Prepare theme
|
2023-01-08 22:27:33 -05:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
final themeService = await ThemeService.instance;
|
2023-07-26 14:20:29 -04:00
|
|
|
final initTheme = themeService.initial;
|
2023-01-11 19:17:04 -05:00
|
|
|
|
2023-07-22 23:29:10 -04:00
|
|
|
// Manage window on desktop platforms
|
2023-07-28 20:36:05 -04:00
|
|
|
await WindowControl.initialize();
|
2023-01-11 19:17:04 -05:00
|
|
|
|
2023-07-07 19:33:28 -04:00
|
|
|
// Make localization delegate
|
2023-07-26 14:20:29 -04:00
|
|
|
final delegate = await LocalizationDelegate.create(
|
2023-07-07 19:33:28 -04:00
|
|
|
fallbackLocale: 'en_US', supportedLocales: ['en_US']);
|
|
|
|
|
2023-07-22 23:29:10 -04:00
|
|
|
// Start up Veilid and Veilid processor in the background
|
|
|
|
unawaited(initializeVeilid());
|
|
|
|
|
2023-01-11 19:17:04 -05:00
|
|
|
// Run the app
|
|
|
|
// Hot reloads will only restart this part, not Veilid
|
2023-07-07 19:33:28 -04:00
|
|
|
runApp(ProviderScope(
|
|
|
|
observers: const [StateLogger()],
|
|
|
|
child: LocalizedApp(delegate, VeilidChatApp(theme: initTheme))));
|
2023-01-07 21:43:31 -05:00
|
|
|
}
|