草庐IT

question_type

全部标签

dart - 如何检查对象是否属于实例 `Type` ?

我有一个函数如下void(Typetype,dynamicinstance){//Unabletodothisif(instanceistype){}}我想检查传递的实例是否与传递的type类型相同。type可以是基类,instance可以是基类的实现,所以只需(instance.runtimeType==type)还不够。 最佳答案 您不能使用运行时Type对象这样做。要实现类似的功能,您必须改用泛型函数:voidfoo(dynamicinstance){if(instanceisT){}}

dart - 如何检查对象是否属于实例 `Type` ?

我有一个函数如下void(Typetype,dynamicinstance){//Unabletodothisif(instanceistype){}}我想检查传递的实例是否与传递的type类型相同。type可以是基类,instance可以是基类的实现,所以只需(instance.runtimeType==type)还不够。 最佳答案 您不能使用运行时Type对象这样做。要实现类似的功能,您必须改用泛型函数:voidfoo(dynamicinstance){if(instanceisT){}}

asynchronous - flutter : Question about Futures and async function

我有几个关于在dart中使用Futures的问题。假设我正在使用firestore,并且我有这样的功能来更新用户的信息:voidupdateOldUser(UseroldUser,StringnewInfo){DocumentReferenceuserToUpdateRef=userRef.document(oldUser.id);Firestore.instance.runTransaction((Transactiontransaction)async{DocumentSnapshotuserToUpdateSnapshot=awaittransaction.get(userToU

asynchronous - flutter : Question about Futures and async function

我有几个关于在dart中使用Futures的问题。假设我正在使用firestore,并且我有这样的功能来更新用户的信息:voidupdateOldUser(UseroldUser,StringnewInfo){DocumentReferenceuserToUpdateRef=userRef.document(oldUser.id);Firestore.instance.runTransaction((Transactiontransaction)async{DocumentSnapshotuserToUpdateSnapshot=awaittransaction.get(userToU

types - 使用 Dart 中的类型初始化一个实例

假设我有一些Type实例:finalstrType=String;finalintType=int;我想初始化Type的实例,例如,最好是,finalmyString=strType();//myStringisString()或finalmyInt=newintType();//myIntisint()但是,编译器引发了错误:strTypeisn'tafunction。是否可以在Dart中初始化Type的实例? 最佳答案 这在语言层面是不可能的。反射是可能的,但代码会很复杂,要在web上使用它或flutter需要代码生成器。与其将

types - 使用 Dart 中的类型初始化一个实例

假设我有一些Type实例:finalstrType=String;finalintType=int;我想初始化Type的实例,例如,最好是,finalmyString=strType();//myStringisString()或finalmyInt=newintType();//myIntisint()但是,编译器引发了错误:strTypeisn'tafunction。是否可以在Dart中初始化Type的实例? 最佳答案 这在语言层面是不可能的。反射是可能的,但代码会很复杂,要在web上使用它或flutter需要代码生成器。与其将

USB显示器,USB Type-c /DP1.4 MST HUB芯片及方案

1.台湾慧荣SM768,可做USB显示器,输入USB,输出可做HDMI,VGA,LVDS,EDP,MIPI各种接口;也可用来做MSTHUB,对于有些苹果电脑不支持MST,本芯片也可以支持。2.芯凯KTM5000,原megachip,专业做Type-c/DP1.4MSTHUB芯片,DP1.4/Type-c进,支持 三路HDMI或者DP输出,带MST,DP和HDMI任意搭配,可选择2HDMI+1DP或者2DP+1HDMI等,预留USB输出,最大支持8K60 17788761040。 

json - 发生异常 : type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>' in type cast

您好,我正在学习flutter并从api获取json,但是在我的模型中对其进行解码时,出现下面列出的错误。我知道这与我的分页有关,因为定位结果很好,但无法弄清楚我需要做什么来修复分页结果。我尝试了很多教程,但没有运气。谁能指出我正确的方向以解决此问题?提前致谢错误Exceptionoccured:type'_InternalLinkedHashMap'isnotasubtypeoftype'List'intypecast*location.dartclassLocations{finalStringid;finalStringname;finalStringstreet;finalSt

json - 发生异常 : type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>' in type cast

您好,我正在学习flutter并从api获取json,但是在我的模型中对其进行解码时,出现下面列出的错误。我知道这与我的分页有关,因为定位结果很好,但无法弄清楚我需要做什么来修复分页结果。我尝试了很多教程,但没有运气。谁能指出我正确的方向以解决此问题?提前致谢错误Exceptionoccured:type'_InternalLinkedHashMap'isnotasubtypeoftype'List'intypecast*location.dartclassLocations{finalStringid;finalStringname;finalStringstreet;finalSt

firebase - flutter 错误 : type 'Future<dynamic>' is not a subtype of type 'List<Game>'

我正在尝试构建一个包含不同游戏列表的应用。作为后端,我使用Firebase并且连接工作正常,我对其进行了测试。无论如何,我在用来自firebase的真实数据替换模拟数据时遇到了问题。我总是收到此错误:type'Future'isnotasubtypeoftype'List'我有以下功能:getGames()async{ListnewGamesList=[];QuerySnapshotresult=awaitFirestore.instance.collection('products').getDocuments();Listdocuments=result.documents;doc