Created
April 13, 2021 22:25
-
-
Save shinayser/0624dfac8b64d411c8eb6e776852de0a to your computer and use it in GitHub Desktop.
Get flutter dir on PATH
This file contains hidden or 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
import 'package:path/path.dart' as path; | |
String getFlutterBinFolderPath() { | |
final pathString = Platform.environment['PATH']; | |
if (pathString == null) { | |
throw 'Flutter bin folder not located on PATH'; | |
} | |
final flutterPath = pathString.split(';').firstWhere( | |
(element) => path.canonicalize(element).contains('flutter\\bin'), | |
orElse: () => throw 'Could not find a proper flutter/bin folder on PATH'); | |
return flutterPath; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment