【发布时间】:2014-01-19 22:37:03
【问题描述】:
在我的 HTML 文件中:
<script>
var serverName = "dev.myapp.com:8080";
</script>
然后,在我的 Dart 代码中:
import "dart:js" as js;
String SERVER_NAME = js.context["serverName"];
String SIGNIN_PLACE_URL = "http://$SERVER_NAME/signin";
String SIGNOUT_PLACE_URL = "http://$SERVER_NAME/signout";
class Place {
static const SigninPlace = const Place._(SIGNIN_PLACE_FRAGMENT_URL);
static const SignoutPlace = const Place._(SIGNOUT_PLACE_FRAGMENT_URL);
static get values => [SigninPlace, SignoutPlace];
final String fragmentURL;
const Place._(this.fragmentURL);
}
在我的“枚举”中,我的两个值的 fragmentURL 参数都出现错误:
创建常量的参数必须是常量表达式
所以看起来我需要制作这些fragmentURLs const,但不确定如何制作。这里有什么解决办法?
【问题讨论】:
标签: enums environment-variables constants dart dart2js