Access to user environment variable

前端 未结 1 571
既然无缘
既然无缘 2020-12-18 23:04

In my .bashrc file:

export DART_SDK=/home/nicolas/dart/dart-sdk

In command line, it works when I \

相关标签:
1条回答
  • 2020-12-18 23:41

    Using the following code:

    import 'dart:io'; // Server side / command line only package.
    
    main() {
      Map<String, String> env = Platform.environment;
      env.forEach((k, v) => print("Key=$k Value=$v"));
    }
    

    I was able to override environment variables on both Windows and Mac. On Mac I had to add the line to .bash_profile (.bashrc is not loaded on my Mac).

    John

    Here is the link to dart docs: https://api.dartlang.org/1.13.0/dart-io/Platform-class.html

    0 讨论(0)
提交回复
热议问题