我使用 Hive 和 Flutter 来存储密钥为字母数字字符串的联系人,每个联系人数据都是一个带有时间戳的地图
框行=
Key. => Value
'abc123' => {'name': 'JK', 'country':'GB', 'timestamp': '568'},
'etergb' => {'name': 'FS', 'country':'DE', 'timestamp': '425'}
'546hfg' => {'name': 'TD', 'country':'GB', 'timestamp': '687'}
Run Code Online (Sandbox Code Playgroud)
现在可以使用where country=GB条件过滤这些并按 map.item.timestamp ASC/DESC 对行进行排序
我正在使用插件 google_maps_flutter 1.2.0,我想实例化一个 GoogleMapController 来测试一些块的事件,其中控制器的值不能为空。不幸的是,我不知道该怎么做,因为据我所知,GoogleMapController 无法在 GoogleMap() Widget 的“OnCreated”函数之外实例化。
GoogleMap(onMapCreated: (GoogleMapController controller) {
// Can only be instanciate here
},
);
Run Code Online (Sandbox Code Playgroud)
不可能做这样的事情:
GoogleMapController controller = new GoogleMapsController();
Run Code Online (Sandbox Code Playgroud)
我只能这样做,并且控制器为 null :
GoogleMapController controller;
Run Code Online (Sandbox Code Playgroud)
我尝试了多种方法,但没有任何效果,有人可以帮助我吗?
当我在 Android Studio 4.1.2 中以配置文件模式运行应用程序时:
\n\n显示此错误:
\nException: Profile mode is not supported for iPhone 11 Pro.\nRun Code Online (Sandbox Code Playgroud)\n为什么会发生这种情况以及我应该采取什么措施来解决它?这是我的环境:
\n~/source/dabai/microservice/soa-illidan-hub on \xee\x82\xa0 feature/cardrobot \xe2\x8c\x9a 22:29:08\n$ ~/apps/flutter/bin/flutter doctor\nDoctor summary (to see all details, run flutter doctor -v):\n[\xe2\x9c\x93] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-CN)\n\n[\xe2\x9c\x93] Android toolchain - develop for Android devices (Android SDK version 30.0.3)\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 12.4)\n[!] Android Studio (version 4.1)\n \xe2\x9c\x97 Flutter plugin not …Run Code Online (Sandbox Code Playgroud) 我有 Web 开发背景,只是 Flutter 和 Dart 的初学者。
对于一个项目,我需要在 Flutter 中实现 Server-Sent-Event / EventSource 功能。
我搜索了 dart:http EventSource 构造函数和 Flutter StreamBuilder 等选项,但没有找到 API 的工作示例。
您能给我一些 Flutter 应用程序可以监听 API 的示例吗?
这就是 Web 开发中要做的事情。
// client side
const eventSource = new EventSource(`/eventSource/${xyz}`)
eventSource.onmessage = function(e) {
const data = JSON.parse(e.data)
console.log(e)
}Run Code Online (Sandbox Code Playgroud)
// server side
router.get('/eventSource/:id', (req, res) => {
const headers = {
'Content-Type': 'text/event-stream',
'Connection': 'keep-alive',
'Cache-Control': 'no-cache'
}
res.writeHead(200, headers)
const data = `data: ${JSON.stringify(someData)}\n\n`
setInterval(() => {
x.write(data)
}, …Run Code Online (Sandbox Code Playgroud)我试图显示这样的数据:
Burger..........................$9.99
Steak and Potato...............$14.99
Mac and Cheese..................$6.99
Run Code Online (Sandbox Code Playgroud)
如何在 Flutter 中实现它?
我正在尝试检测模拟位置。我已经安装了假位置应用程序并在“设置”(在“开发人员选项”下)中启用了“模拟位置”。但是当我尝试使用Geolocator检测模拟位置时,它根本不起作用。
Future<Position> _determinePosition() async {
bool serviceEnabled;
LocationPermission permission;
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
return Future.error('Location services are disabled.');
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.deniedForever) {
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission != LocationPermission.whileInUse &&
permission != LocationPermission.always) {
return Future.error(
'Location permissions are denied (actual value: $permission).');
}
}
return await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high);
} …Run Code Online (Sandbox Code Playgroud) 我遇到一种情况,我希望在点击小部件时可以看到模态底部工作表。此代码可以正常工作(来自小部件,它基本上是一张“卡片”):
return Container(
color: Colors.white,
margin: EdgeInsets.symmetric(horizontal: 5.0),
child: Material(
child: InkWell(
onTap: () {
showMaterialModalBottomSheet(
expand: false,
context: context,
builder: (context) =>
customiseItemScreen(item: this.item,),
);
},
...
...
Run Code Online (Sandbox Code Playgroud)
但是,我还想在customiseItemScreen小部件中显示一个浮动操作按钮。当涉及到脚手架时,很容易理解:
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton:
...
...
Run Code Online (Sandbox Code Playgroud)
但由于customiseItemScreen返回一个材质(没有支架),因此上述成员不存在。有没有更好的方法来解决这个问题,或者现有代码中可能缺少的解决方案?
提前致谢,
我正在使用 Google 地图 API,我需要使用一些 TextFormField 在 google 地图上显示一些容器。我面临的问题是我需要滚动谷歌地图顶部的容器。也就是说,当用户将容器从下往上移动时,容器才会像这样来到顶部。
我的代码
Stack(children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: GoogleMap(
markers: Set<Marker>.of(_markers.values),
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: currentPostion,
zoom: 18.0,
),
myLocationEnabled: true,
onCameraMove: (CameraPosition position) {
if (_markers.length > 0) {
MarkerId markerId = MarkerId(_markerIdVal());
Marker marker = _markers[markerId];
Marker updatedMarker = marker.copyWith(
positionParam: position.target,
);
setState(() {
_markers[markerId] = updatedMarker;
});
}
},
),
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
child: Container(
color: Colors.white, …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 上运行我的集成测试Firebase Test Lab。
flutter build apk -t lib/main_dev.dart
./gradlew app:assembleAndroidTest -Ptarget=lib/main_dev.dart
./gradlew app:assembleDebug -Ptarget=integration_test/login_test.dart
Run Code Online (Sandbox Code Playgroud)
该代码生成app-debug-androidTest.apk,app-debug.apk一旦我在Test Lab测试中上传它们,它们就会完美执行。
现在的问题是我在integration_test. 我不确定如何创建一个app-debug-androidTest.apk 包含 下所有测试用例的测试用例integration_test。
我确实尝试了以下操作:
flutter build apk -t lib/main_dev.dart
./gradlew app:assembleAndroidTest -Ptarget=lib/main_dev.dart
./gradlew app:assembleDebug -Ptarget=test_driver/integration_test.dart
Run Code Online (Sandbox Code Playgroud)
但是这个测试卡在黑屏上,这很奇怪,但这是正确的行为,因为在本地设备中运行集成测试时,我们还需要提供目标和驱动程序。
所以对于本地我有一个脚本
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/login_test.dart
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/register_test.dart
Run Code Online (Sandbox Code Playgroud)
它运行所有集成代码。
所以我的问题是如何上传所有测试用例。
或者我们是否必须为每个测试用例进行构建
./gradlew app:assembleDebug -Ptarget=integration_test/login_test.dart
Run Code Online (Sandbox Code Playgroud)
然后将其上传到测试实验室,然后再次上传
./gradlew app:assembleDebug -Ptarget=integration_test/register_test.dart
Run Code Online (Sandbox Code Playgroud)
并再次上传?
flutter ×10
dart ×2
google-maps ×2
android ×1
bottom-sheet ×1
flutter-hive ×1
geolocation ×1
modal-dialog ×1
testing ×1