草庐IT

dynamic-properties

全部标签

dynamic - Flutter - 创建动态数量的文本编辑 Controller

我正在重新创建一个我以前用Swift制作的应用程序,在我的一个页面上,我们调用一个API,并根据结果向用户显示动态数量的文本字段,以通过不同的搜索参数进行搜索。在Dart/Flutter中有什么好的方法可以做到这一点吗?由于dart不支持在运行时生成代码,这甚至有可能吗? 最佳答案 我刚刚修改了@Felix的答案,使用Map来存储TextEditingControllers而不是列表。我认为用键值对调用textEditingControllers很容易。修改代码块;import'package:flutter/material.da

flutter - child : and children: property in Flutter? 和有什么区别

Flutter中的child:和children:属性有什么区别?我从Flutter官方文档开始学习Flutter2周,感觉不像学习Android那样容易。 最佳答案 child采用单个小部件child:Text('foo')children获取小部件列表children:[Text('foo'),Text('bar')] 关于flutter-child:andchildren:propertyinFlutter?和有什么区别,我们在StackOverflow上找到一个类似的问题:

android-studio - flutter Android Studio : Error retrieving device properties for ro. product.cpu.abi:

想要改进这篇文章?提供这个问题的详细答案,包括引用和解释为什么你的答案是正确的。没有足够细节的答案可能会被编辑或删除。当我尝试在AndroidStudio的模拟器中运行我的应用程序时,我收到以下错误。我不得不说它在SDK到v.29的一些更新之后工作并停止工作。我现在有什么需要改变的吗?到目前为止,我试图杀死并重新启动adb服务器并禁用堆保护..Errorretrievingdevicepropertiesforro.product.cpu.abi:Launchinglib\main.dartonAndroidSDKbuiltforx86indebugmode...Initializin

json - 错误 : List<dynamic> is not a subtype of type Map<String, 动态>

我目前正在构建一个应用程序来通过api读取数据,并且我正在尝试从JSONPlaceholder解析JSONapi。我为用户创建了一个模型类(users_future_model.dart):classUsers{finalintuserID;finalStringname;finalStringusername;finalStringemail;finalAddressaddress;Users({this.userID,this.name,this.username,this.email,this.address});factoryUsers.fromJson(Mapusersjso

firebase - 类型 'List<dynamic>' 不是类型 'List<Widget>' 的子类型

我有一段从Firestore示例复制的代码:Widget_buildBody(BuildContextcontext){returnnewStreamBuilder(stream:_getEventStream(),builder:(context,snapshot){if(!snapshot.hasData)returnnewText('Loading...');returnnewListView(children:snapshot.data.documents.map((document){returnnewListTile(title:newText(document['name

android - Dagger2 + Kotlin : lateinit property has not been initialized

我正在尝试将ViewModelFactory注入(inject)到我的Activity中,但它一直抛出同样的错误:lateinit属性viewModelFactory尚未初始化。我找不到我可能做错了什么。从我的类(class)中查看上面的代码AppComponent.kt@Component(modules=[(AppModule::class),(NetworkModule::class),(MainModule::class)])interfaceAppComponent{funinject(application:TweetSentimentsApplication)funinj

android - 未初始化的属性访问异常 : lateinit property pref has not been initialized

我知道有人回答了类似的问题Here.但那是由于黄油刀库问题,但我的情况不同。在我的情况下,当我在基本Activity中使用Dagger注入(inject)属性时,它会显示错误Causedby:kotlin.UninitializedPropertyAccessException:lateinitpropertyprefhasnotbeeninitialized但是当我在我的子Activity(登录Activity)中使用相同的属性时,它可以正常工作。例如。pref.setLanguage("abc")->它在登录Activity中工作正常,但在基本Activity中引发错误这是我的代码

Kotlin 数据类 : how to read the value of property if I don't know its name at compile time?

如果属性名称仅在运行时已知,我如何读取Kotlin数据类实例中的属性值? 最佳答案 这是一个从给定属性名称的类的实例中读取属性的函数(如果未找到属性则抛出异常,但您可以更改该行为):importkotlin.reflect.KProperty1importkotlin.reflect.full.memberProperties@Suppress("UNCHECKED_CAST")funreadInstanceProperty(instance:Any,propertyName:String):R{valproperty=instan

android - Kotlin 属性 : "Type parameter of a property must be used in its receiver type"

我有以下简单的Kotlin扩展函数://GettheviewsofViewGroupinlinevalViewGroup.views:Listget()=(0..childCount-1).map{getChildAt(it)}//GettheviewsofViewGroupofgiventypeinlinefunViewGroup.getViewsOfType():List{returnthis.views.filterIsInstance()}这段代码可以编译并且运行良好。但是,我希望函数getViewsOfType成为一个属性,就像views一样。AndroidStudio甚至建

kotlin - Interface 的函数与 Property 的 getter 冲突

接口(interface)的函数名故意与属性的getter名冲突,但由于意外覆盖问题被编译器禁止。是否可以指示编译器这是故意的?interfaceA{fungetFoo()}classB:A{valfoo} 最佳答案 此功能似乎没有以任何方式实现。@AndreyBreslav对similarquestion的评论:YoucannotoverrideJavamethodswithKotlinpropertiesatthemoment.Itwouldbeniceifwecouldsupportit,butwedon'tknowhowto