import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:servermanager/settings.dart'; class Proton extends StatefulWidget { Settings settings; Proton({super.key, required this.settings}); @override ProtonState createState() => ProtonState(settings: settings); } Future runProton(String command, List argx) async { Settings settings = Settings(); Directory dir = Directory(settings.game_path + Platform.pathSeparator + "pfx"); if (dir.existsSync()) { await dir.delete(recursive: true); } await dir.create(recursive: true); Map env = Map.from(Platform.environment); env["STEAM_COMPAT_CLIENT_INSTALL_PATH"] = "~/.steam"; env["STEAM_COMPAT_DATA_PATH"] = dir.path; try { List args = ["run", command]; args.addAll(argx); ProcessResult res = await Process.run( "proton", args, // Run arbitrary command with arguments environment: env, ); print('Exit code: ${res.exitCode}'); print('stdout: ${res.stdout}'); print('stderr: ${res.stderr}'); } catch (e) { print('Error executing command: $e'); } } class ProtonState extends State { Settings settings; ProtonState({required this.settings}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Proton Manager"), backgroundColor: Color.fromARGB(255, 100, 0, 0), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(16), child: Column( children: [ ListTile( title: Text("Init Prefix"), subtitle: Text("Resets proton prefix"), leading: Icon(CupertinoIcons.folder_fill), onTap: () { runProton( "echo", ["hello"]); // Change to "cmd" to execute 'cmd' }, ) ], ), ), ), ); } }