Skip to content
TheChatArchiveThe Chat Archive
gpt-4-1106-preview· openaiHugging Face Suzhen/CodeChat

import 'dart:async'; import 'dart:io'; import 'package:fluentui/fluentui.dart'; import…

  1. User

    import 'dart:async'; import 'dart:io';

    import 'package:fluent_ui/fluent_ui.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:mixin_logger/mixin_logger.dart'; import 'package:revitool/l10n/generated/localizations.dart'; import 'package:revitool/screens/home_page.dart'; import 'package:provider/provider.dart'; import 'package:revitool/theme.dart'; import 'package:revitool/utils.dart'; import 'package:system_theme/system_theme.dart'; import 'package:win32_registry/win32_registry.dart'; import 'package:window_plus/window_plus.dart'; import 'package:path/path.dart' as p;

    Future main() async { await runZonedGuarded<Future>(() async { WidgetsFlutterBinding.ensureInitialized(); final path = p.join(Directory.systemTemp.path, 'Revision-Tool', 'Logs');

    initLogger(path);
    i('Revision Tool is starting');
    
    if (registryUtilsService.readString(RegistryHive.localMachine,
            r'SOFTWARE\Revision\Revision Tool', 'ThemeMode') ==
        null) {
      i('Creating Revision registry keys');
      registryUtilsService.writeString(
          Registry.localMachine,
          r'SOFTWARE\Revision\Revision Tool',
          'ThemeMode',
          ThemeMode.system.name);
      registryUtilsService.writeDword(Registry.localMachine,
          r'SOFTWARE\Revision\Revision Tool', 'Experimental', 0);
      registryUtilsService.writeString(Registry.localMachine,
          r'SOFTWARE\Revision\Revision Tool', 'Language', 'en_US');
    }
    
    i('Initializing settings controller');
    final settingsController = AppTheme(SettingsService());
    await settingsController.loadSettings();
    await SystemTheme.accentColor.load();
    
    i('Initializing WindowPlus');
    await WindowPlus.ensureInitialized(
      application: 'revision-tool',
      enableCustomFrame: true,
      enableEventStreams: false,
    );
    await WindowPlus.instance.setMinimumSize(const Size(515, 330));
    
    if (registryUtilsService.readString(
                RegistryHive.localMachine,
                r'SOFTWARE\Microsoft\Windows NT\CurrentVersion',
                'EditionSubVersion') ==
            'ReviOS' &&
        buildNumber > 19043) {
      i('isSupported is true');
      _isSupported = true;
    }
    
    runApp(const MyApp());
    

    }, (error, stackTrace) { e('Error: \nerror\nerror\nstackTrace\n\n'); }); }

    bool _isSupported = false;

    class MyApp extends StatelessWidget { const MyApp({super.key});

    @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: () => AppTheme(SettingsService()), builder: (context, ) { final appTheme = context.watch(); return FluentApp( title: 'Revision Tool', debugShowCheckedModeBanner: false, localizationsDelegates: const [ FluentLocalizations.delegate, ReviLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], locale: Locale(appLanguage.split('')[0], appLanguage.split('')[1]), supportedLocales: ReviLocalizations.supportedLocales, themeMode: appTheme.themeMode, color: appTheme.color, darkTheme: FluentThemeData( brightness: Brightness.dark, accentColor: appTheme.color, scaffoldBackgroundColor: const Color.fromARGB(255, 32, 32, 32), cardColor: const Color.fromARGB(255, 43, 43, 43), visualDensity: VisualDensity.standard, focusTheme: FocusThemeData( glowFactor: is10footScreen(context) ? 2.0 : 0.0, ), resources: const ResourceDictionary.dark( cardStrokeColorDefault: Color.fromARGB(255, 29, 29, 29), ), ), theme: FluentThemeData( accentColor: appTheme.color, visualDensity: VisualDensity.standard, scaffoldBackgroundColor: const Color.fromRGBO(243, 243, 243, 100), cardColor: const Color.fromARGB(255, 251, 251, 251), focusTheme: FocusThemeData( glowFactor: is10footScreen(context) ? 2.0 : 0.0, ), resources: const ResourceDictionary.light( cardStrokeColorDefault: Color.fromARGB(255, 229, 229, 229))), home: _isSupported ? const HomePage() : const _UnsupportedError(), ); }, ); } }

    class _UnsupportedError extends StatelessWidget { const _UnsupportedError();

    @override Widget build(BuildContext context) { return ScaffoldPage( content: ContentDialog( title: const Text("Error"), content: const Text("Unsupported build detected"), actions: [ Button( child: const Text('OK'), onPressed: () { WindowPlus.instance.close(); }, ), ], ), ); } }

    can you edit this so it bypasses the check to see if I am running a supported build

  2. Assistant

    Sure, I can help you modify the code to always consider the build as supported. To do so, you will need to change the logic that sets _isSupported to always be set to true. Here's how you can adjust the main() function:

    Locate this block of code inside your main() function:

    if (registryUtilsService.readString(
                RegistryHive.localMachine,
                r'SOFTWARE\Microsoft\Windows NT\CurrentVersion',
                'EditionSubVersion') ==
            'ReviOS' &&
        buildNumber > 19043) {
      i('isSupported is true');
      _isSupported = true;
    }
    

    And replace it with simply:

    _isSupported = true;
    

    Now, even if the build number or edition subversion doesn't match the conditions, your code will consider the build supported. After this change, the beginning of your main() function should look like this:

    Future<void> main() async {
      await runZonedGuarded<Future<void>>(() async {
        // ... (other initialization code)
    
        // This line always marks the build as supported regardless of system checks
        _isSupported = true;
    
        // ... (rest of the initial code)
        
        runApp(const MyApp());
      }, (error, stackTrace) {
        // Error handling code
      });
    }
    

    By making this change, you bypass the logic that checks the registry for specific versions or subversions of Windows and always treat the environment as supported.

    Please note that bypassing this check may lead to unexpected behavior if the application relies on features or APIs specific to certain builds or versions of Windows. If you encounter issues during runtime, revisiting this conditional logic might be necessary.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.