我需要从 Firebase Cloud Firestore 获取 1 个字段 1 次。如何通过 Widget 构建之外的提供者来实现此目的?
以下是我的组合提供商。appStartupProvider
是一个 FutureProvider,我想bool
从 firestore 中的这个 1 字段中获取值。但是,状态中的等待appStartupProvider
“'await'应用于'AsyncValue',这不是'Future'”。
final accountStreamProvider = StreamProvider<Account>((ref) {
final database = ref.watch(databaseProvider);
return database != null ? database.accountStream() : const Stream.empty();
});
final _accountSetupCompleteProvider = Provider<AsyncValue<bool>>((ref) {
return ref
.watch(accountStreamProvider)
.whenData((account) => account?.accountSetupComplete ?? false);
});
final appStartupProvider = FutureProvider<bool>((ref) async {
final accountSetupComplete = await ref.watch(_accountSetupCompleteProvider);
return accountSetupComplete;
});
Run Code Online (Sandbox Code Playgroud)
显然,这里缺少一些有关组合提供程序和 AsyncValue 的关键知识,但我正在尝试实现RiverPod 组合提供程序页面上所述的情况,我在其中看到正在使用等待。
在当前版本的 flutter 3.0.1 中,我们在 index.html 中有一个 Service Worker。到目前为止,我在 flutter.dev 上找不到任何有关如何在屏幕或代码更新时强制刷新缓存的文档。刷新的唯一方法是使用浏览器刷新按钮等。
有很多过时的建议,通过在此处或那里附加一些内容来手动更改版本号,但这不适用于服务工作者。每次构建时,服务工作线程在运行时flutter build web
都会自动获取新的版本号。但是,这不会强制刷新浏览器中的缓存。
默认情况下,这个 Service Worker js 正在监听 a statechange
,然后调用console.log('Installed new service worker.');
这仅在您单击浏览器的刷新按钮时调用,因此提示或强制刷新新内容没有帮助。
我尝试使用flutter build web --pwa-strategy=none
,这也不影响缓存。
有什么好主意可以强制刷新吗?在我构建的其他网站中,对 css/js 文件进行版本控制非常容易,这将在没有任何用户交互的情况下强制刷新,但我没有看到任何清晰的flutter build web
.
web/index.html
.运行后,flutter build web
将var serviceWorkerVersion = null
变得像var serviceWorkerVersion = '1767749895';
部署到托管并在网络上运行时一样。但是,此 serviceWorkerVersion 更新不会强制刷新内容。
<script>
var serviceWorkerVersion = null;
var scriptLoaded = false;
function loadMainDartJs() {
if (scriptLoaded) {
return;
}
scriptLoaded = …
Run Code Online (Sandbox Code Playgroud) 我有两个单独的 firebase 控制台,可以从两个单独的谷歌帐户访问。
最初,我使用 flutterfire cli 设置了 Firebase“A”控制台flutterfire configure
,效果很好,但设置“B”时,似乎存在某种针对“A”问题的缓存。
在我完全独立的 Firebase 控制台“B”Google 帐户中,我创建了一个项目,现在需要flutterfire configure
在项目“B”的单独目录中运行该项目。
使用firebase login:add a@gmail.com
和firebase login:add b@gmail.com
. 两个帐户都已验证,没有问题。所以我应该能够firebase login:use
在两者之间切换,但是flutterfire configure
似乎firebase projects:list
不尊重我登录的 firebase 帐户。他们只显示“A”的项目,从不显示“B”的项目。
例如,切换到 firebase 项目“B”的目录,我运行firebase login:use b@gmail.com
然后flutterfire configure --account=b@gmail.com
. flutterfire configure
,错误的是“A”中的 3 个项目。firebase projects:list
运行后在目录“B”中运行firebase login:use b@gmail.com
,仅显示“A”中的项目,而不是我期望从项目“B”中看到的 1 个项目。
在项目“B”的目录中,我尝试运行firebase init
,它正确列出了我的“B”1 个项目,并且我能够初始化。但在 init 之后,立即在“B”的目录中运行flutterfire …
初始化/配置 FlutterFire时,firebase_options.dart
会在/lib
. 该文件包含适用于 android、ios、web 以及您可能使用的任何渠道的 api 密钥。这些公钥是可以进入存储库的还是私有的并且不应该提交到存储库?没有关于 FlutterFire 的详细信息,并且创建它/lib
似乎表明这些是公钥。
有时我认为我已经理解了提供者的逻辑,然后我在尝试做下面的事情时被难住了几个小时。
我需要从 firestore collectionsstream 获取连接 ID 列表。简单的。
但是,我需要将这个连接 ID 的流列表提供到另一个 Firestore 集合流中。下面,您可以看到我即将推出的EventsStreamProvider 是 ref.watch 数据库和connectionsStream。Riverpod 或 firestore 没有抛出任何错误。但是,在日志中,我按以下顺序看到打印语句:
returned data
returned null stream value
Run Code Online (Sandbox Code Playgroud)
我如何滥用 Riverpod 提供商的权力?哈哈。
final connectionsStreamProvider = StreamProvider<List<UidConnections>>((ref) {
final database = ref.watch(databaseProvider);
return database != null ? database.connectionsStream() : Stream.value(null);
});
final connectionsListStateProvider = StateProvider<List>((ref) => []);
final upcomingEventsStreamProvider = StreamProvider<List<SpecialEvents>>((ref) {
final database = ref.watch(databaseProvider);
final connectionsStream = ref.watch(connectionsStreamProvider);
if (database != null && connectionsStream != null) {
connectionsStream.whenData((data) {
if (data != null) { …
Run Code Online (Sandbox Code Playgroud) 我的目标是使用Guzzle 6创建一个PUT json数据的异步请求池.然后监控每个$ promise成功/失败.
为了与我的POOL代码示例进行比较,对$ client-> request()的以下单个请求将第3个参数转换为编码的json,然后添加Content-type:application/json.**
$client = new Client([
'base_uri' => BASE_URL . 'test/async/', // Base URI is used with relative requests
'timeout' => 0, // 0 no timeout for operations and watching Promises
]);
$response = $client->request('PUT', 'cool', ['json' => ['foo' => 'bar']]);
Run Code Online (Sandbox Code Playgroud)
在接收API端点上,我可以通过执行以下操作从上面的单个请求中读取json:
$json = file_get_contents('php://input');
$json = json_decode($json, true);
Run Code Online (Sandbox Code Playgroud)
使用文档中的并发请求示例,为了使用新的Request()创建异步请求池,我希望可以使用相同的参数(方法,url端点,json标志),就像在单个$ client->请求中一样( )上面的例子.但是,yield new Request()
不处理第3个json参数$client->request()
.从我的池代码调用正确设置json和内容类型的Guzzle函数是什么?或者是否有更好的方法来创建大量异步请求并监视其结果?
POOL代码示例:
$this->asyncRequests = [
[
'endpoint' => 'cool' …
Run Code Online (Sandbox Code Playgroud) 在浏览器中打开机器人验证之前,会记录以下内容:“SafetyNet 证明基本完整性失败”。
此应用程序未发布到 Google Play,只是在模拟器和物理 Android 设备上进行测试。
验证码返回后,codeSent
返回,其他verifyPhoneNumber()
参数工作正常。
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: '$_countryCode$_phoneNumber',
verificationCompleted:(PhoneAuthCredential credential) {
print('verificationCompleted'); …
Run Code Online (Sandbox Code Playgroud) dart firebase firebase-authentication flutter flutter-dependencies
pub.dev 上有几个提供视频压缩的著名软件包。我已经尝试过它们以及其他粗略的软件包,但一旦视频达到 300MB 左右,没有一个可以很好地工作。它们在各种平台和硬件上崩溃或存在其他问题。即视频压缩器和光压缩器。GH 提交和支持也与我在 pub.dev 中看到的视频压缩包有关。PR 没有被拉进来,问题也没有及时解决,对于最近的 Android APK 更新来说,有些问题相当严重。所以这不是我想要的依赖堆栈中的东西。
\n我正在使用 FlutterFire 上传到 Google Cloud Storage。虽然我的代码确实使用FireBaseStorage 上传任务进行上传,但它无法在客户端压缩或在应用程序关闭时处理后台上传。
\n因此,目前在服务器端,我有一个在文件上传时触发的 GCF。然后我使用nodejs ffmpeg,它被烘焙到GCF中以压缩服务器端并转换为H264。最后删除原来上传的大视频并将压缩视频保存到存储中。
\n这个解决方案是有效的,但是根据用户的连接以及他们是否在wifi上,可能需要很长的时间,并且当它失败或用户关闭应用程序时,我当前的解决方案是无用的。
\n我希望 Android 和 iOS 上有一个可靠的本机库,我可以利用它,自信地执行从任何格式到 H264 的压缩和转换,并且无论我的应用程序是关闭的还是在后台,都允许上传到 GC 存储。有什么想法吗?我希望这是 FlutterFire 云存储处理的标准!
\n我还没有测试flutter_ffmpeg,但这只是因为有些人说它在客户端上运行得很慢。再说一次,Flutter/Dart 可以访问原生编写的代码,但我不知道在 Android/iOS 上从哪里开始才能以正确的方式做到这一点。我知道这就是某些软件包正在做的事情,但它们不适用于大型视频,所以我希望有人能在 Android 和 iOS 上为我指明正确的方向。
\n我的代码用于处理上传任务到 GC 存储。
\n \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xe2\x80\x8bFuture<\xe2\x80\x8bvoid\xe2\x80\x8b>\xe2\x80\x8b\xc2\xa0\xe2\x80\x8buploadTask\xe2\x80\x8b({ \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xe2\x80\x8brequired\xe2\x80\x8b\xc2\xa0\xe2\x80\x8bWidgetRef\xe2\x80\x8b\xc2\xa0ref, \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xe2\x80\x8brequired\xe2\x80\x8b\xc2\xa0\xe2\x80\x8bFile\xe2\x80\x8b\xc2\xa0file, \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xe2\x80\x8brequired\xe2\x80\x8b\xc2\xa0\xe2\x80\x8bString\xe2\x80\x8b\xc2\xa0objectPath, \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xe2\x80\x8bSettableMetadata\xe2\x80\x8b?\xe2\x80\x8b\xc2\xa0metaData, \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xe2\x80\x8bbool\xe2\x80\x8b\xc2\xa0deleteAfterUpload\xc2\xa0\xe2\x80\x8b=\xe2\x80\x8b\xc2\xa0\xe2\x80\x8bfalse\xe2\x80\x8b, \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xe2\x80\x8bbool\xe2\x80\x8b\xc2\xa0displayProgressNotification\xc2\xa0\xe2\x80\x8b=\xe2\x80\x8b\xc2\xa0\xe2\x80\x8bfalse\xe2\x80\x8b, \n \xe2\x80\x8b\xc2\xa0\xc2\xa0})\xc2\xa0\xe2\x80\x8basync\xe2\x80\x8b\xc2\xa0{ \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xe2\x80\x8bString\xe2\x80\x8b\xc2\xa0filePath\xc2\xa0\xe2\x80\x8b=\xe2\x80\x8b\xc2\xa0file.path; \n \xe2\x80\x8b\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0filename\xc2\xa0\xe2\x80\x8b=\xe2\x80\x8b\xc2\xa0\xe2\x80\x8bbasename\xe2\x80\x8b(file.path); \n …
Run Code Online (Sandbox Code Playgroud) 使用 aws/aws-sdk-php 3.21.6。当 ConditionExpression 遇到 ConditionalCheckFailedException 错误时,我一定误解了 ReturnValues 的工作原理。
我希望的是,如果 ConditionExpression 失败,进而触发 ConditionalCheckFailedException,我可以捕获此异常,然后通过 ReturnValues 访问 DD 中的新属性。
我期望从 ReturnValues 获得的文档属性似乎暗示了这一点。
然而,根据测试,ReturnValues 仅在 ConditionExpression 为 true 时返回属性,而不是在失败时返回属性。
$response = $client->updateItem([
'TableName' => 'MyTable',
'Key' => [
'customer_url' => [
'S' => 'someurl.com'
],
'customer_platform' => [
'S' => 'some_platform'
]
],
'ExpressionAttributeNames' => [
'#C' => 'createdAt'
],
'ExpressionAttributeValues' => [
':val1' => [
'S' => '2017-01-24T14:15:32'
],
':val2' => [
'S' => '2017-01-24T14:15:30'
]
],
'UpdateExpression' => 'set #C …
Run Code Online (Sandbox Code Playgroud) Android Studio 花栗鼠 | 2021.2.1 补丁 1 版本 #AI-212.5712.43.2112.8609683,构建于 2022 年 5 月 18 日 运行时版本:11.0.12+0-b1504.28-7817840 amd64 VM:JetBrains sro Linux 5.4 的 OpenJDK 64 位服务器 VM。 199-1-曼扎罗
如果我尝试在 Android Studio 模拟器中打开 Chrome 浏览器,当我看到“打开同步?”时 屏幕上,如果我点击“不,谢谢”或“是的,我在”,模拟器就会完全锁定。我无法滑动并关闭 Chrome 浏览器或执行任何操作。我只能让模拟器崩溃。然后我“擦除数据”并重试。
有人知道如何解决这个问题,以便我可以在模拟器中打开 Chrome 浏览器吗?Webviewer 工作得很好,但直接在模拟器中打开 Chrome 却不行。
我尝试过不同的 SDK,但目前我找不到解决这个奇怪问题的方法。
在 Manjaro Linux 上。
运行 Android Studio 3.6.3。一切正常,但是当我尝试启动任何模拟器时,我收到此错误:
Emulator: createOrGetGlobalVkEmulation: Warning: Vulkan 1.1 APIs missing from device
除了尝试使用 Android Studio 模拟器之外,我没有遇到任何驱动程序问题。
我在 manjaro 中安装了 Radeon 的 Vulkan mesa 驱动程序。我还在 BIOS 中为处理器启用了虚拟化。
System: Host: command Kernel: 5.4.40-1-MANJARO x86_64 bits: 64 compiler: gcc v: 9.3.0
CPU: Topology: 8-Core model: AMD Ryzen 7 2700X bits: 64 type: MT MCP arch: Zen+ rev: 2 L2 cache: 4096 KiB
Graphics: Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere …
Run Code Online (Sandbox Code Playgroud) Mysql is in it's own docker-compose.yml as I want a mysql server up and running that any other php application can connect to. So I do not have php and mysql in the same docker-compose.yml. From the php application, I can connect to mysql if I use the mysql container's gateway ip address by looking it up and then hard coding it into the php application. docker inspect mysql-db
. But docker will change that 172... ip address each time …
在Chrome浏览器中,当尝试从远程URL测试画布绘图图像时,在jsfiddle上收到以下错误。
错误:无法在“ HTMLCanvasElement”上执行“ toDataURL”:可能无法导出污染的画布。
在S3存储桶上,我具有以下CORS策略,该策略允许跨资源共享:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
</CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)
如果我使用jsfiddle卷曲图像作为原点,则会得到:
curl -H 'Origin: https://fiddle.jshell.net' -I 'https://i.ezr.io/products3/472_ARDSCR.jpg?h=45&w=165&fit=scale'
HTTP/1.1 200 OK
Cache-Control: public,max-age=31536000
Last-Modified: Wed, 07 Feb 2018 23:42:47 GMT
Server: imgix-fe
Content-Length: 6371
Accept-Ranges: bytes
Date: Fri, 16 Mar 2018 17:10:20 GMT
Age: 3173253
Connection: keep-alive
Content-Type: image/jpeg
Access-Control-Allow-Origin: *
X-Content-Type-Options: nosniff
X-Served-By: cache-lax8630-LAX, cache-sea1027-SEA
X-Cache: HIT, HIT
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
</CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)
var Rack = {
init: function(params) …
Run Code Online (Sandbox Code Playgroud)