草庐IT

flutter - 类型 'Future<dynamic>' 不是类型转换中类型 'List<dynamic>' 的子类型

我试图从我的firestore中获取确定集合中的所有文档,之后,我想将它们设置在文档列表中,列表的每个位置代表一个文档。但是,当我编写代码时,我收到了这个错误:类型“Future”不是类型转换中类型“List”的子类型import'package:cloud_firestore/cloud_firestore.dart';classRestaurant{Stringkeyword;Stringstate;Stringaddress;Stringcity;intevaluation;Stringimage;Stringphone;doublerating;Stringschedule;S

dart - Future 结合 Flutter 中的 FutureBuilder 返回 null

我想使用FutureBuilder检查url是否为png图像,然后构建一个或两个图像(在列表中)。但是不知何故,当我打印它时,Future总是返回null...结果是应用程序始终使用两个CachedNetworkImages构建ListView,这不是我想要的。如果URL是图像,它应该只使用该url构建一个CachedNetworkImage,如果不是,它应该更改url并构建一个包含2个图像的ListView。child:newFutureBuilder(future:_getImages(widget.imgUrl),builder:(BuildContextcontext,Asyn

asynchronous - Flutter Future<dynamic> 与 Future<String> 子类型错误?

我刚刚更新了Flutter,并成功地从git下载了我的原始项目。现在我遇到了一个奇怪的Future错误。我在github上看到在线提到它,但没有关于如何修复的明确答案。该项目甚至不加载。它从我的main.dart文件中读取Future语句并返回这个...[VERBOSE-2:dart_error.cc(16)]Unhandledexception:type'Futuredynamic'isnotasubtypeoftype'FutureString'whereFutureisfromdart:asyncFutureisfromdart:asyncStringisfromdart:cor

Flutter 从 future<File> 创建字符串以检查文件名的最后 3 个字符

我正在使用返回路径字符串的image_picker,它是一个future,所以当我得到future时,我希望能够检查最后3个字符是图像还是电影的文件类型。当我尝试子字符串时,我尝试的一切似乎都无法将字符串设置为Future或int相同。我显示的代码是用于返回所选文件的futurebuilder的容器。如果您想查看其他内容,请告诉我。newContainer(alignment:Alignment.bottomLeft,padding:newEdgeInsets.only(left:10.0),child:newFutureBuilder(future:_imageFile,builde

dart - future 的功能不断重复

我正在尝试在我的flutter应用程序中读取和写入文件......像这样:Futureget_localPathasync{print('hi');finaldirectory=awaitgetApplicationDocumentsDirectory();returndirectory.path;}Futureget_localFileasync{finalpath=await_localPath;Filef=File('$path/mypollshash.txt');if(f.existsSync()){print('exists');Stringcontents=awaitf.r

dart - Flutter Dart : Future. wait() 通过引用传递值?

在如下场景中,如何传递一个变量ListitemList通过引用?Future.wait([futDocs]).then((dataRet){dataRet.forEach((doco){vardocList=doco.documents;docList.forEach((doc){vardocTitle=doc['title'];print("datais$docTitle");itemList.add(docTitle);itemListitemList.add(docTitle)时不会改变在上面的Future.wait()中执行。我相信原因是因为itemList不通过引用传递。如果

dart - 有没有办法将 Future<List<String>> 转换为 List<dynamic>?

编辑:主页-我正在从我的firebase集合中获取一个字符串列表。然后我想调用firestore存储并获取可下载的图像链接并将其存储在我将传递给第2页的列表中。下面的代码是我获取可下载链接的方式。Future>test(Listimages)async{ListlistOfImages=List();for(inti=0;i然后我按以下方式传递图像列表Navigator.push(context,MaterialPageRoute(builder:(context)=>CarDetailScreen(carImages:test(car['images']))),);第2页-我收到一个

asynchronous - Future 函数中的 SetState

我喜欢为我future的功能自动同步。我尝试了一个setstate,但它没有正常工作。你有想法吗?对建议很满意。FuturequeryFunc()async{AlgoliaQueryquery=algolia.instance.index('groups').setAroundLatLng('51.5078845,7.4702625');Futuresnap=query.getObjects();returnsnap;} 最佳答案 此代码是如何构建等待异步代码的小部件的示例。Widgetmywidget=newFutureBuild

asynchronous - Dart 中的 Stream 和 Future

我使用基本的async/await已经有一段时间了,没有遇到太多问题,我想我理解它是如何工作的。不能说我是这方面的专家,但我理解它的要点。不过,我只是无法理解Streams。在今天之前,我以为我了解它们是如何工作的(基本上就是响应式编程),但我无法让它们在Dart中工作。我正在研究一个可以保存和检索(json)文件的持久层。我一直在使用fileManagerexample作为指南。import'dart:io';import'dart:async';import'package:intl/intl.dart';//dateimport'package:markdowneditor/mo

dart - getter 中的 future 对象

我在我的getter中为我的Locale变量调用一个future对象。如何让返回值等待呢?classChangeLocalewithChangeNotifier{Locale_locale;Localegetlocale{getLanguage().then((LocaleprefLocale){_locale=prefLocale;});return_locale;}setlocale(LocalenewValue){print(newValue);_locale=newValue;notifyListeners();}} 最佳答案