【发布时间】:2020-04-02 19:52:25
【问题描述】:
我正在将变量从一个活动传递到另一个活动,但收到错误“无法使用静态访问访问实例成员'纬度'”我需要在该块中对其进行转换,以便将其分配给静态 URL。
class Xsecond extends StatefulWidget {
final double latitude;
final double longitude;
Xsecond(this.latitude, this.longitude, {Key key}): super(key: key);
@override
_Xsecond createState() => _Xsecond();
}
class _Xsecond extends State<Xsecond> {
static String lat = Xsecond.latitude.toString(); // Error: Instance member ‘latitude’ can’t be accessed using static access
...
紧随其后
...
String url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${lat},$lng&radius=$radius&type=restaurant&key=$api';
...
【问题讨论】:
-
@Morez 试过这个。不幸的是,这不起作用,但将错误更改为“初始化程序只能访问静态成员”
标签: flutter dart static instance