gpt4 book ai didi

flutter - 带有提供程序的FutureBuilder:列表不是Future 类型的子类型

转载 作者:行者123 更新时间:2023-12-03 04:47:02 25 4
gpt4 key购买 nike

我需要以动态方式创建元素列表,并且用户可以自然地对其进行修改,其想法是在将数据插入显示给我的那些元素或这些元素之后

  FutureBuilder<List<Detalleconcepto>>(
future: provider.listado,
builder: (BuildContext context,
AsyncSnapshot<List<Detalleconcepto>> snapshot) {
if (snapshot.hasData) {
return _listConceptos(snapshot.data);
} else {
return Center(
child: contenedor(),
);
}
},
),

我将保留提供者模型和列表的引用
class ProviderInfo with ChangeNotifier {
List<Detalleconcepto> _listado = new List<Detalleconcepto>();

get listado {
return _listado;
}

set listado(List<Detalleconcepto> listado) {
this._listado = listado;
notifyListeners();
}
}
class Detalleconcepto {
int idOperacionFinanciera;
int idTipoConcepto;
String tipoConcepto;
double importe;
String fecha;
String numeroDocumento;

Detalleconcepto({
this.idOperacionFinanciera,
this.idTipoConcepto,
this.tipoConcepto,
this.importe,
this.fecha,
this.numeroDocumento,
});

widget由小部件库捕获的异常═══════════════════════════════════
“列表”类型不是“ future >”类型的子类型

相关的引起错误的小部件是
创建 list

enter image description here

最佳答案

仅当您拥有以FutureBuilder返回的数据(即异​​步)时,才需要Future
由于在您的情况下,数据是通过同步返回的,因此您不需要FutureBuilder:

_listConceptos(provider.listado), // instead of FutureBuilder

关于flutter - 带有提供程序的FutureBuilder:列表不是Future <List>类型的子类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62107363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com