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

48 lines
1.1 KiB
Dart
Raw Normal View History

2022-01-16 16:19:01 +00:00
import 'dart:async';
import 'package:flutter/material.dart';
2022-12-09 23:59:31 +00:00
import 'package:flutter/foundation.dart';
2022-01-16 16:19:01 +00:00
import 'package:veilid/veilid.dart';
2022-12-09 23:59:31 +00:00
import 'package:flutter_acrylic/flutter_acrylic.dart';
2022-03-10 14:51:53 +00:00
2022-12-10 17:11:46 +00:00
import 'veilid_color.dart';
import 'log.dart';
import 'app.dart';
import 'veilid_init.dart';
2022-12-09 23:59:31 +00:00
/////////////////////////////// Acrylic
bool get isDesktop {
if (kIsWeb) return false;
return [
TargetPlatform.windows,
TargetPlatform.linux,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
}
Future<void> setupAcrylic() async {
await Window.initialize();
await Window.makeTitlebarTransparent();
2022-12-10 17:11:46 +00:00
await Window.setEffect(
effect: WindowEffect.aero, color: const Color(0xFFFFFFFF));
2022-12-09 23:59:31 +00:00
await Window.setBlurViewState(MacOSBlurViewState.active);
2022-02-15 18:40:17 +00:00
}
2022-12-09 23:59:31 +00:00
/////////////////////////////// Entrypoint
2022-01-16 16:19:01 +00:00
void main() {
2022-03-04 01:45:39 +00:00
WidgetsFlutterBinding.ensureInitialized();
2022-12-10 17:11:46 +00:00
// Initialize Log
2022-03-04 01:45:39 +00:00
initLoggy();
2022-12-10 17:11:46 +00:00
// Initialize Veilid
veilidInit();
// Run the app
2022-03-04 01:45:39 +00:00
runApp(MaterialApp(
title: 'Veilid Plugin Demo',
2022-12-10 17:11:46 +00:00
theme: newVeilidTheme(),
2022-03-04 01:45:39 +00:00
home: const MyApp()));
2022-01-16 16:19:01 +00:00
}