-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from leoafarias/fix/crash-on-process
Fix/crash on process
- Loading branch information
Showing
20 changed files
with
171 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:fvm/fvm.dart'; | ||
import 'package:sidekick/utils/helpers.dart'; | ||
|
||
class FlutterConfigService { | ||
FlutterConfigService._(); | ||
|
||
/// Runs a simple Flutter cmd | ||
static Future<String> _runCmd( | ||
List<String> args, | ||
) async { | ||
// Get exec path for flutter | ||
final globalVersion = await FVMClient.getGlobal(); | ||
|
||
if (globalVersion == null) { | ||
throw Exception( | ||
'Can only check flutter settings with a global version configured', | ||
); | ||
} | ||
|
||
final result = await Process.run(globalVersion.flutterExec, args); | ||
|
||
if (result.exitCode == 0) { | ||
return result.stdout as String; | ||
} else { | ||
return result.stderr as String; | ||
} | ||
} | ||
|
||
/// Sets Flutter config | ||
static Future<void> setFluterConfig(Map<String, bool> config) async { | ||
final analytics = | ||
config['analytics'] == true ? '--analytics' : '--no-analytics'; | ||
final web = config['web'] == true ? '--enable-web' : '--no-enable-web'; | ||
final macos = config['macos'] == true | ||
? '--enable-macos-desktop' | ||
: '--no-enable-macos-desktop'; | ||
final windows = config['windows'] == true | ||
? '--enable-windows-desktop' | ||
: '--no-enable-windows-desktop'; | ||
final linux = config['linux'] == true | ||
? '--enable-linux-desktop' | ||
: '--no-enable-linux-desktop'; | ||
|
||
await _runCmd([ | ||
'config', | ||
analytics, | ||
macos, | ||
windows, | ||
linux, | ||
web, | ||
]); | ||
} | ||
|
||
/// Returns configured Flutter settings | ||
static Future<Map<String, bool>> getFlutterConfig() async { | ||
final result = await _runCmd(['config']); | ||
final analytics = containsIgnoringWhitespace( | ||
result, | ||
'Analytics reporting is currently enabled', | ||
); | ||
final macos = containsIgnoringWhitespace( | ||
result, | ||
'enable-macos-desktop: true', | ||
); | ||
final windows = containsIgnoringWhitespace( | ||
result, | ||
'enable-windows-desktop: true', | ||
); | ||
final linux = containsIgnoringWhitespace( | ||
result, | ||
'enable-linux-desktop: true', | ||
); | ||
final web = containsIgnoringWhitespace( | ||
result, | ||
'enable-web: true', | ||
); | ||
|
||
return { | ||
'analytics': analytics, | ||
'macos': macos, | ||
'windows': windows, | ||
'linux': linux, | ||
'web': web, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.