Skip to content

Instantly share code, notes, and snippets.

@shinayser
Created April 13, 2021 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinayser/0624dfac8b64d411c8eb6e776852de0a to your computer and use it in GitHub Desktop.
Save shinayser/0624dfac8b64d411c8eb6e776852de0a to your computer and use it in GitHub Desktop.
Get flutter dir on PATH
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