我有一个运行 Rocket.rs 的后端,我的 Flutter Web 应用程序向它发送请求,但它无法通过 OPTIONS 响应。
我曾尝试将 CORS (rocket_cors) 添加到后端并有一个选项响应,但它仍然发回:
Error: XMLHttpRequest error.
dart:sdk_internal 124039:30 get current
packages/http/src/browser_client.dart.lib.js 214:124 <fn>
Run Code Online (Sandbox Code Playgroud)
我在我的火箭项目中添加了以下内容:
Error: XMLHttpRequest error.
dart:sdk_internal 124039:30 get current
packages/http/src/browser_client.dart.lib.js 214:124 <fn>
Run Code Online (Sandbox Code Playgroud)
我的颤振应用程序正在运行此请求:
Future<String> fetchData() async {
final data2 = await http.get("http://my-web-site.com").then((response) { // doesn't get past here
return response.body;
});
return data2;
}
Run Code Online (Sandbox Code Playgroud)
问题:这是响应 OPTION 请求的正确方法,如果不是,我如何在 Rocket.rs 中实现它?
我正在使用 Flutter 并想使用 parser.dart 解析 HTML
<div class="weather-item now"><!-- now -->
<span class="time">Now</span>
<div class="temp">19.8<span>?</span>
<small>(23?)</small>
</div>
<table>
<tr>
<th><i class="icon01" aria-label="true"></i></th>
<td>93%</td>
</tr>
<tr>
<th><i class="icon02" aria-label="true"></i></th>
<td>south 2.2km/h</td>
</tr>
<tr>
<th><i class="icon03" aria-label="true"></i></th>
<td>-</td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
使用,导入 'package:html/parser.dart';
我想得到这个数据
现在,19.8,23,93%,南 2.2km/h
我怎样才能做到这一点?
我正在为一个项目使用 flutter web 和 firebase,但遇到了一个问题。我正在尝试更新 firestore 数组中的地图。
使用这个:
var val = [];
val.add({'groupUID': groupUID, 'inviteStatus': status});
var userInviteUID;
await users
.document(uid)
.get()
.then((value) => userInviteUID = value.data['inviteUID']);
await invites
.document(userInviteUID)
.updateData({'invites': FieldValue.arrayUnion(val)});
Run Code Online (Sandbox Code Playgroud)
我得到了这个结果: firestore结构
我想要做的只是将地图中的 1 更改为 2。我认为它会更新,因为它的值相同,但它只是将它添加到数组中。
我环顾堆栈,看到了一些方法,例如复制整个数组并在需要的地方更改它,然后将其添加回来。
但我想知道是否有办法通过对我的代码添加一些修改来避免这种情况。也让我知道是否有更好的结构我应该使用。感谢帮助!
更新:
var ref = invites.document(userData.inviteUID);
ref.get().then((value) async {
var invitesList = value.data['invites'];
switch (status) {
case 1:
break;
case 2:
var index;
invitesList.asMap().forEach((key, value) {
if (value['groupUID'] == groupUID) index = key;
});
invitesList.removeAt(index);
await invites
.document(userData.inviteUID)
.updateData({'invites': FieldValue.arrayUnion(invitesList)});
break; …Run Code Online (Sandbox Code Playgroud) 使用以下代码从 url 下载图像时,我的 get 请求被 CORS 策略阻止:
await get(product.imageUrl).then((img) async {
print('image downloaded');
var dwnldProd = product;
dwnldProd.productImage = img.bodyBytes;
await _productRepository.saveProduct(dwnldProd);
}).catchError((e) {
print('downloading product image error: $e');
});
Run Code Online (Sandbox Code Playgroud)
正如No 'Access-Control-Allow-Origin' header is present on the requested resource.所说我的请求缺少标题,所以我将它们添加为:
await get(product.imageUrl, headers: <String,String>{
'Access-Control-Allow-Origin': '*', // Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
// 'Access-Control-Allow-Origin':'http://localhost:5000/', // Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
"Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, …Run Code Online (Sandbox Code Playgroud) 我想在 PC 和移动设备上使用不同的应用程序,那么在加载应用程序之前找出设备的最佳方法是什么?
有没有办法让 Flutter Web 应用程序进入全屏模式(隐藏地址栏、标签栏和任务栏)?或者有没有办法以编程方式按下 F11?
我试过了...
@override
void dispose() {
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
super.dispose();
}
@override
initState() {
SystemChrome.setEnabledSystemUIOverlays([]);
super.initState();
}
Run Code Online (Sandbox Code Playgroud)
但它在网络应用程序中不起作用(我没想到会这样)
我想构建一个基于 flutter web 的 PWA,它依赖于扫描二维码并访问用户的当前位置。
根据我对这两个功能的了解,目前没有可用的软件包。
但是,为了获取用户的位置,有一个 stackoverflow 线程(Get User's Location for flutter Web)提供了解决方案。
所以我想知道是否有可能针对 QR 扫描问题有类似的解决方案?
遗憾的是,我对 web 和 javascript 开发不是很熟悉。因此,任何帮助将不胜感激。
我正在尝试在网络上发布我现有的 flutter 项目(它已经在 iOS 和 android 上运行)。
根据这篇很棒的文章: 如何在 WordPress 中嵌入你的 Flutter 应用程序
我到了将 build/web 文件夹复制到我的存储库并推送到 master 的地步。我确保存储库中存在所有内容。
但是在 https://username.github.io/app_folder 上什么也没有出现
只是一个空白页:(
我正在尝试开发一个 flutter 应用程序,该应用程序将 http 请求发送到托管在 000webHost 上的远程 php 文件。
当我为桌面构建 Flutter 应用程序时,我设法检索了信息,一切都很好。但是,由于另一个问题(视频播放器不适用于桌面....),我想回到网络构建。
我查看了几个帖子,但没有发现与我类似的错误。有人说由于跨源请求 (CORS) 导致错误,但在我看来这不是这个问题。
当我尝试使用 http.post 检索我的数据时,出现以下错误:
browser_client.dart:87 POST https://<myadresse>.000webhostapp.com/<nameFile>.php net::ERR_HTTP2_PROTOCOL_ERROR
Run Code Online (Sandbox Code Playgroud)
Uncaught (in promise) Error: XMLHttpRequest error.
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28 get current packages/http/src/browser_client.dart 84:22 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1446:54 runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 150:18 handleValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 703:44 handleValueCallback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 732:32 _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 526:7 [_complete]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream_pipe.dart 61:11 _cancelAndValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/stream.dart 1302:7 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14 _checkAndCall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39 dcall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/html/dart2js/html_dart2js.dart 37312:58 <fn>
at Object.createErrorWithStack (errors.dart:249)
at Object._rethrow (async_patch.dart:200)
at async._AsyncCallbackEntry.new.callback (zone.dart:1171)
at Object._microtaskLoop (schedule_microtask.dart:41)
at _startMicrotaskLoop (schedule_microtask.dart:50) …Run Code Online (Sandbox Code Playgroud) 我正在 flutter web 上构建一个应用程序,最近在我的程序中添加了一个文本字段。最近的一个新更新增加了对使用空格键滚动的支持。有没有办法禁用或拦截最近实现的空格键滚动功能?空格键滚动功能可以在开发频道的任何可滚动列表上重现(例如列表视图)
Body(child:ListView(children:[TextField(),Container(height:10000,width:100)]))
Run Code Online (Sandbox Code Playgroud) flutter-web ×10
flutter ×7
dart ×5
http ×2
cors ×1
firebase ×1
flutter-http ×1
get ×1
github-pages ×1
html ×1
javascript ×1
qr-code ×1
rust ×1
rust-rocket ×1