import 'dart:html' as html; import 'dart:io' as io; import 'package:flutter/material.dart'; import 'backend.dart'; import 'user_checker.dart'; class Config { static String? backendUrl; // Declare it as nullable static void loadConfig() { if (html.window.location.origin.isNotEmpty) { // For web applications backendUrl = html.window.location.origin; // Get the server URL from window.location } // For Android or other platforms, check for the environment variable /*if (io.Platform.environment.containsKey('BACKEND_URL')) { backendUrl = io.Platform.environment['BACKEND_URL']; } else if (html.window.location.origin.isNotEmpty) { // For web applications backendUrl = html.window.location.origin; // Get the server URL from window.location } else { // If no value is determined, set it to null backendUrl = null; }*/ } } void main() { print("Main"); Config.loadConfig(); // Load the configuration before running the app Backend.setup('${Config.backendUrl}/ws'); runApp(HubApp()); } class HubApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Horde Hub', theme: ThemeData.dark(), home: UserChecker(), ); } }