0

我在 Flutter 中创建了一些测试,但是我需要在运行测试之前设置一个环境变量。从这些“运行|调试”按钮运行应用程序时,有没有办法设置环境变量?

在此处输入图像描述

4

1 回答 1

2

随着 Dart SDK 的新更新,它是可能的: https ://dartcode.org/releases/v3-11/

[...] 例如,为启动配置添加 CodeLens,将RELEASE_MODE=true环境变量设置为测试test/integration_tests

{
    "name": "Current File (release mode)",
    "type": "dart",
    "request": "launch",
    "codeLens": {
        // Types of CodeLens to inject
        "for": [ "run-test", "run-test-file", "debug-test", "debug-test-file" ],
        // Restrict to certain folders
        "path": "test/integration_tests",
        // Text for CodeLens link (${debugType} will be replaced with "run" or "debug")
        "title": "${debugType} (release)"
    },
    "env": { "RELEASE_MODE": true }
}

这会将额外的 CodeLens 链接插入到测试、组和主要功能中:

于 2020-05-31T23:06:55.450 回答