美好的一天,伙计们。我正在 flutter 中制作一个足球比分实时数据应用程序。我不知道如何解决这个问题,如果我使用 http.get,我将不得不每次刷新才能获取最新数据。我不知道 StreamBuilder 是否有效以及如何进行。在此先感谢您的帮助。
我正在使用 Redux 和 Flutter 以及这个库。如果解决方案是更改为 redux dart 库,那么我会更改它。
这是我为商店提供的代码,我一直在从不同的教程中获取部分内容
@immutable
class AppState {
final SignUpState signUpState;
final LoginState loginState;
AppState({
@required this.signUpState,
@required this.loginState,
});
AppState copyWith({
SignUpState signUpState,
LoginState loginState,
}) {
return AppState(
signUpState: signUpState ?? this.signUpState,
loginState: loginState ?? this.loginState,
);
}
}
AppState appReducer(AppState state, action) {
return AppState(
signUpState: signUpReducer(state.signUpState, action),
// loginState: loginReducer(state.loginState, action),
);
}
class Redux {
static Store<AppState> _store;
static Store<AppState> get store {
if (_store == null) { …Run Code Online (Sandbox Code Playgroud) 抱歉这个菜鸟问题。但是如何从 Uri 获取 Url 字符串?根据我的理解,Url 是 Uri 的子集,但我找不到任何类似.getUrl. 我错过了什么吗?
背景:Flutter Web 中的 FirebaseStorage 以某种方式返回
而不是.getDownloadURL()UriString
来自 Flutter Web 的 FirebaseStorage 包的解释:
Future<Uri> getDownloadURL() 包:firebase/src/storage.dart
返回此引用的长期下载 URL。
getDownloadURL来自Flutter App 的FirebaseStorage 包的解释:
Future<String> getDownloadURL() 包:firebase_storage/firebase_storage.dart
获取该对象的长期下载 URL。
在 Flutter 应用程序中我的 pubspec.yaml:
firebase_core: ^0.5.1
firebase_auth: ^0.18.2
cloud_firestore: ^0.14.2
firebase_storage: ^5.0.0-dev.4
Run Code Online (Sandbox Code Playgroud)
在 Flutter Web 中我的 pubspec.yaml:
firebase: ^7.3.2
cloud_firestore: ^0.14.2
cloud_functions: ^0.6.0+1
Run Code Online (Sandbox Code Playgroud)
我尝试寻找解决方案并阅读文档,但没有找到任何有关将 Uri 从 Firebase 存储getDownloadURL方法转换为 Url 的文章。似乎几乎被视为同一件事。但这给了我错误。参见下面的代码:
*** 代码:
Future<String> uploadImage(String localFilename, …Run Code Online (Sandbox Code Playgroud) 根据文档,localhost应该与所有端口一起列入白名单:https://support.google.com/firebase/answer/6400741 ?authuser=0 - 我在控制台和firebase中检查了这一点,并且localhost实际上已列入白名单。
但是当我尝试在 Flutter web 中执行以下操作时,出现未列入白名单的错误:
final GoogleSignIn _googleSignIn;
final googleUser = await _googleSignIn.signIn(); // This is where the error happens
Run Code Online (Sandbox Code Playgroud)
Error: PlatformException(idpiframe_initialization_failed, Not a valid origin for the client: http://localhost:59386 has not been whitelisted for client ID XXXXXX.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID., https://developers.google.com/identity/sign-in/web/reference#error_codes, null)
at Object.createErrorWithStack (http://localhost:59386/dart_sdk.js:4353:12)
at Object._rethrow (http://localhost:59386/dart_sdk.js:37968:16)
at async._AsyncCallbackEntry.new.callback (http://localhost:59386/dart_sdk.js:37962:13)
at Object._microtaskLoop (http://localhost:59386/dart_sdk.js:37794:13)
at _startMicrotaskLoop (http://localhost:59386/dart_sdk.js:37800:13)
at http://localhost:59386/dart_sdk.js:33309:9
Run Code Online (Sandbox Code Playgroud)
我使用这些 dart 依赖项:
cloud_firestore: ^0.14.2
firebase_auth: …Run Code Online (Sandbox Code Playgroud) 我需要你的帮助,我正在 Flutter WEB 中使用插件file_picker上传一个 TXT 文件,它可以工作,之后我想逐行读取内容并处理这些数据,但我不知道该怎么做。 ..
我的代码是这样的:
//load File from txt
loadFile() async {
FilePickerResult result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['txt'],
);
if (result != null) {
PlatformFile file = result.files.first;
print(file.name);
// print(file.bytes);
print(file.size);
print(file.extension);
print(file.path);
print("contenido");
setState(() {
_nameFile = file.name;
_uploadFile = true;
});
}
}
Run Code Online (Sandbox Code Playgroud)
有人有任何想法吗?我正在调查,但没有找到太多相关信息,非常感谢
PD:该项目仅适用于 FLutter Web
我正在寻找一个与 Bootstrap\xe2\x80\x99s Scrollspy 等效的 flutter 包:
\nhttps://getbootstrap.com/docs/4.0/components/scrollspy/
\n预期的功能是有一个垂直可滚动的项目列表,其顶部有一个粘性水平可滚动 \xe2\x80\x9cheader/navbar 菜单\xe2\x80\x9d。当用户滚动垂直列表并到达新的 \xe2\x80\x9csection\xe2\x80\x9d 时,这会通过在导航栏中突出显示 \xe2\x80\x9csection name\xe2\x80\x9d 来反映在水平导航栏中并在必要时滚动到它。当用户按下水平导航栏中的部分名称时,它应该滚动到垂直列表中该部分的开头。
\n前任:
\n第 1 节!!!第 2 节!!!第 3 节 第 4 节\n\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80 \x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94 \xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\xe2\x80\x94\n(Section1 不可见)
\n!!!第2节!!!
\nItem3\n\nItem4\nRun Code Online (Sandbox Code Playgroud)\n第三节
\nItem1\n\nItem2\nRun Code Online (Sandbox Code Playgroud)\n第四节
\nItem5\n\nItem6\nRun Code Online (Sandbox Code Playgroud)\n 运行flutter build web出现如下错误:
flutter build web\nChanging current working directory to: /home/forest/projects/icell/i_cell_parking_manager\n\nBuilding without sound null safety\nFor more information see https://dart.dev/null-safety/unsound-null-safety\n\nTarget dart2js failed: Exception: ../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-1.0.1/lib/src/interop/utils/utils.dart:15:41:\nError: The argument type 'Object? Function(Object)' can't be assigned to the parameter type 'Object? Function(Object?)?' because 'Object?' is nullable and 'Object' isn't.\n - 'Object' is from 'dart:core'.\n return core_interop.dartify(jsObject, (Object object) {\n ^\n../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-1.0.1/lib/src/interop/utils/utils.dart:39:41:\nError: The argument type 'dynamic Function(Object)' can't be assigned to the parameter type 'Object? Function(Object?)?' because 'Object?' is nullable and 'Object' isn't.\n - …Run Code Online (Sandbox Code Playgroud) 这是我的index.html文件代码
<!DOCTYPE html>
<html>
<head>
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.
The path provided below has to start and end with a slash "/" in order for
it to work correctly.
Fore more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
-->
<base href="/">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons --> …Run Code Online (Sandbox Code Playgroud) 当我在 flutter web 中使用 image_picker 时出现问题“错误:不支持的操作:Object.throw 处的命名空间[as throw] (http://localhost:56308/dart_sdk.js:5334:11) at Function.get _namespace [as _namespace] (http://localhost:56308/dart_sdk.js:55299:17) 在 io._File.new.lengthSync (http://localhost:56308/dart_sdk.js:53158:59)'
这在 android 中工作正常,在打开的图像选择窗口中并且图像已成功预览,但在 flutter web 中不起作用在网络案例中图像选择窗口打开但图像未获取。
这是我的图像选择器代码...
最终选择器= ImagePicker(); var imag =等待picker.getImage(来源:oursource);
var imageFile = File(imag.path);
Run Code Online (Sandbox Code Playgroud) 在 flutter web debuggin 上打开一个没有 chrome 扩展的新窗口。但我的项目必须通过扩展进行消息传递。如何防止 Chrome 扩展被禁用?
flutter ×10
flutter-web ×10
firebase ×2
api ×1
imagepicker ×1
listview ×1
plugins ×1
redux ×1
widget ×1