veilidchat/lib/main.dart

64 lines
1.8 KiB
Dart
Raw Normal View History

2023-01-12 00:17:04 +00:00
import 'dart:async';
import 'package:flutter/foundation.dart';
2023-01-08 02:43:31 +00:00
import 'package:flutter/material.dart';
2023-01-09 03:27:33 +00:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
2023-07-23 03:29:10 +00:00
import 'package:flutter_translate/flutter_translate.dart';
import 'package:window_manager/window_manager.dart';
2023-01-12 00:17:04 +00:00
import 'log/log.dart';
import 'veilid_support/veilid_support.dart';
import 'theming/theming.dart';
2023-01-09 03:27:33 +00:00
import 'app.dart';
2023-01-12 00:17:04 +00:00
import 'dart:io';
2023-01-09 03:27:33 +00:00
void main() async {
2023-01-12 00:17:04 +00:00
// Disable all debugprints in release mode
if (kReleaseMode) {
debugPrint = (String? message, {int? wrapWidth}) {};
}
// Print our PID for debugging
if (!kIsWeb) {
debugPrint('VeilidChat PID: $pid');
}
2023-01-09 03:27:33 +00:00
// Logs
initLoggy();
2023-01-12 00:17:04 +00:00
// Prepare theme
2023-01-09 03:27:33 +00:00
WidgetsFlutterBinding.ensureInitialized();
final themeService = await ThemeService.instance;
var initTheme = themeService.initial;
2023-01-12 00:17:04 +00:00
2023-07-23 03:29:10 +00:00
// Manage window on desktop platforms
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
await windowManager.ensureInitialized();
const windowOptions = WindowOptions(
size: Size(768, 1024),
center: true,
backgroundColor: Colors.transparent,
skipTaskbar: false,
titleBarStyle: TitleBarStyle.hidden,
);
windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
await windowManager.focus();
});
}
2023-01-12 00:17:04 +00:00
2023-07-07 23:33:28 +00:00
// Make localization delegate
var delegate = await LocalizationDelegate.create(
fallbackLocale: 'en_US', supportedLocales: ['en_US']);
2023-07-23 03:29:10 +00:00
// Start up Veilid and Veilid processor in the background
unawaited(initializeVeilid());
2023-01-12 00:17:04 +00:00
// Run the app
// Hot reloads will only restart this part, not Veilid
2023-07-07 23:33:28 +00:00
runApp(ProviderScope(
observers: const [StateLogger()],
child: LocalizedApp(delegate, VeilidChatApp(theme: initTheme))));
2023-01-08 02:43:31 +00:00
}