我正在尝试创建值和名称数组。我不知道这样做的正确方法是什么。
var send=[];
send=[
'latitud': widget.lat;
];
Run Code Online (Sandbox Code Playgroud)
有人知道如何创建带有索引和值的数组吗?
在 Flutter 中,我有一张地图,可以在location 的帮助下获取设备 位置。然后我使用这个位置在谷歌地图 Flutter插件的帮助下在谷歌地图中显示标记。
代码类似于
child: GoogleMap(
mapType: MapType.hybrid,
initialCameraPosition: CameraPosition(
target: LatLng(lat, lng),
zoom: 5,
),
markers: Set<Marker>.of(
<Marker>[
Marker(
draggable: true,
markerId: MarkerId("1"),
position: LatLng(lat, lng),
icon: BitmapDescriptor.defaultMarker,
infoWindow: const InfoWindow(
title: 'Usted está aquí',
),
)
],
),
onMapCreated: (GoogleMapController controller) {
mapController = controller;
},
))
Run Code Online (Sandbox Code Playgroud)
如果位置插件失败或获取错误数据,我需要选择重新定位此标记。我使用draggable: true拖动标记,但我需要采用新的纬度和经度将其保存在数据库中。
所以问题是:使用可拖动我怎样才能获得新的纬度和经度?
我正在尝试创建一个表单。这个表单有一个包含 vue、axios 和 sweetalert 的 package.json。
"dependencies": {
"axios": "^0.19.0",
"vue": "^2.6.10",
"vue-sweetalert2": "^2.1.1"
}
Run Code Online (Sandbox Code Playgroud)
JS是
<script>
import Vue from 'vue';
import VueSweetalert2 from 'vue-sweetalert2';
import VueAxios from 'vue-axios';
import axios from 'axios';
import 'sweetalert2/dist/sweetalert2.min.css';
Vue.use(VueSweetalert2, VueAxios, axios);
var app = new Vue({
el: '#app',
methods: {
guardar: function () {
axios
.get('ENDPONT')
.then(response => {
console.log(response);
Vue.swal('Hello Vue world!!!');
})
.catch(function (error) {
console.log(error);
Vue.swal('Hello Vue world!!!');
});
}
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
错误很简单:返回“不能在模块外使用导入语句”。我想导入是错误的,但我是 Vue 新手,不知道什么是正确的方法。
我正在尝试迭代新的Google Flutter Map中的标记。
我使用Web服务检索坐标数组,然后迭代元素并获取具有纬度和经度的索引。
for (int i = 0; i < list.length; i++) {
mapController.addMarker(MarkerOptions(position: list[0].values.elementAt(i)))));
}
Run Code Online (Sandbox Code Playgroud)
和地图选项。
GoogleMapController mapController;
GoogleMap(
onMapCreated: (GoogleMapController mapController) {
mapController = mapController;
},
options: GoogleMapOptions(
mapType: MapType.satellite,
myLocationEnabled :true,
cameraPosition: CameraPosition(
target: LatLng(40.347022, -3.750381), zoom: 5.0),
),
),
Run Code Online (Sandbox Code Playgroud)
我想mapController应该采用我放入for循环中的坐标,但是不起作用。控制台返回
方法“ addMarker”在null上被调用。
所以问题是,如何使用Google Flutter Map包动态添加多个标记?
我也尝试了这个简单的代码并且可以工作,因此添加标记时发生了错误。
GoogleMapController mapController;
GoogleMap(
onMapCreated: (GoogleMapController mapController) {
mapController = mapController;
mapController.addMarker(MarkerOptions(
position:LatLng(40.347022, -3.750381),
infoWindowText: InfoWindowText("Title", "Content"),
//icon:
));
mapController.addMarker(MarkerOptions(
position:LatLng(43.321871, -3.006887),
infoWindowText: InfoWindowText("Title", "Content"),
//icon:
));
}, …Run Code Online (Sandbox Code Playgroud) 在Laravel中,我试图显示Auth :: user(用户)和Departments之间的关系元素。在用户表中,我具有id,name和department_id。在Departments表中,我具有id和name。
在用户模型中,我创建
public function department()
{
return $this->belongsTo('App\Models\Department');
}
Run Code Online (Sandbox Code Playgroud)
然后,在刀片模板中尝试
Auth :: user()->部门
但是返回null,不显示链接的 部门。Null不正确,所有用户都有部门。o,有帮助吗?¿关系有什么问题?
我正在尝试将一个元素发送到一个视图。此元素将是第二页下拉列表中的默认元素。我在第一页使用类似的东西
onTap: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new SummaryPage(,
dropdownItem: dropdownSelection)));
}
Run Code Online (Sandbox Code Playgroud)
然后在第二页我创建未来以获取下拉列表中的所有元素和 initstate 方法来设置默认元素下拉列表
List data = List();
Future<Null> getEstates() async {
final response = await http
.get('URL'
}).catchError((error) {
print(error.toString());
});
final responseJson = json.decode(response.body);
final getBody = responseJson['body'];
setState(() {
data = getBody;
loading = false;
});
}
void initState() {
super.initState();
setState(() {
dropdownSelection = widget.dropdownItem.toString();
});
Run Code Online (Sandbox Code Playgroud)
getEstate 返回这个
[{id: 1, 描述: Terreno Rio}, {id: 2, 描述: Terreno Asier}]
下拉看起来类似于这个
child: ButtonTheme( …Run Code Online (Sandbox Code Playgroud) 我想在flutter项目中添加这个包。为什么是这个图表?因为它\xc2\xb4s有负条
\n\n我尝试添加这样的东西
\n\n charts_flutter:\n git:\n url: git://github.com/jeroentrappers/charts.git\n path: charts/charts_flutter/\n name: charts\n ref: master\nRun Code Online (Sandbox Code Playgroud)\n\n但返回
\n\n\n\n\n在 git://github.com/jeroentrappers/charts.git\n ee7a2110386f7b3e6476eb9ff815c11a65875195 中找不到名为“charts/charts_flutter/pubspec.yaml”的文件。
\n
那么添加这种类型的git包的正确方法是什么呢?
\n问题很简单:在数组中搜索元素的正确方法是什么?
我的代码是
data = [{id: 1, descripcion: Asier}, {id: 2, descripcion: Pepe}]
estateSelected= data.firstWhere((dropdown)=>dropdown.id==1);
Run Code Online (Sandbox Code Playgroud)
返回的错误是
坏状态:没有元素
我正在尝试使用本地化获取移动国家代码和语言代码
Widget build(BuildContext context) {
Locale myLocale = Localizations.localeOf(context);
print(myLocale.countryCode);
print(myLocale.languageCode);
return MaterialApp(
title: 'Title',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: LoginPage(),
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
Locale('es' 'ES'),
],
);
}
Run Code Online (Sandbox Code Playgroud)
但是返回“未找到本地化祖先”。有人知道这样做的正确方法是什么?
我用Flutter创建了一个应用程序。当我上传新版本时,我需要强制用户更新应用程序。我尝试了这个包,但我认为它不起作用。在文档中,我们可以看到我们可以使用此代码验证版本。
Container(
margin: EdgeInsets.fromLTRB(12.0, 0.0, 12.0, 0.0),
child: UpgradeCard();
)
Run Code Online (Sandbox Code Playgroud)
问题是:我需要检查 *'initState' 中的版本,而不是Scaffold。那么在应用程序启动时检查版本的正确方法是什么?
flutter ×8
dart ×5
google-maps ×2
dropdown ×1
geolocation ×1
laravel ×1
localization ×1
vue.js ×1