Start Cloudflare resolution after app starts

- Defer the Cloudflare resolution webserver until after runApp().

- await said function
This commit is contained in:
NBA2K1 2025-11-28 23:59:37 +01:00
parent e0ecc94869
commit 5c34dcab9a
2 changed files with 4 additions and 2 deletions

View file

@ -50,7 +50,6 @@ DiscordRPC? discordRpc;
WebViewEnvironment? webViewEnvironment;
String? customDns;
void main(List<String> args) async {
cfResolutionWebviewServer();
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isLinux && runWebViewTitleBarWidget(args)) return;
MediaKit.ensureInitialized();
@ -93,6 +92,7 @@ Future<void> _postLaunchInit(StorageProvider storage) async {
await discordRpc?.initialize();
}
await storage.deleteBtDirectory();
await cfResolutionWebviewServer();
}
class MyApp extends ConsumerStatefulWidget {

View file

@ -292,7 +292,9 @@ class ResolveCloudFlareChallenge extends RetryPolicy {
}
int cfPort = 0;
void cfResolutionWebviewServer() async {
/// Cloudflare Resolution Webview Server
Future<void> cfResolutionWebviewServer() async {
final server = await HttpServer.bind(InternetAddress.loopbackIPv4, cfPort);
cfPort = server.port;