我试图从Firebase实时数据库检索数据到一个使用模型的颤振列表中。当我这样做时,我的列表返回为null。我读过其他几篇关于使用Firebase的文章,但是还没有找到明确的答案。下面是我当前的方法(该对象称为“需要”,我正在尝试检索和显示需求列表):
型号:
import 'package:firebase_database/firebase_database.dart';
class Need {
final String id;
final String imageUrl;
final String caption;
final String title
我试图从第三方API(https://randomuser.me/api/?results=50)中获取数据,但遇到了以下错误:
E/flutter (18902): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
E/flutter (18902): #0 ProfileProvider.fetchData.<anonymous clo
我正在尝试从JSON中的值创建一个列表。我可以得到长度,但不能得到数据的长度。我的主要目标是根据项目的受欢迎程度创建一个项目列表。 child: Row(
children: [
...List.generate(
"items"[0].length,
(index) {
if (["items"][index].isPopular) { // here I want to generate
未处理的异常:类型“String”不是类型类型“int”的子类型
else if (value is List<int>) {
prefs.setStringList(
"itemsToLoanCats", [...value.map((e) => e.toString())]);
}
“值”的类型= List<int>
我不明白为什么这不管用,我用的是.toString()
堆栈跟踪
I/flutter (16996): Person This is claiming to be
我想要显示一个图标和文本作为下拉菜单中的每个项目。根据这个答案,https://stackoverflow.com/a/65831827/7870443我试过了。但是我的代码不能工作。我看到一个下划线和下拉按钮。但不能点击。 这就是我得到的。I see an underline and dropdown button. But not clickable. 下面是我在该link中尝试的代码 import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart
这适用于DropdownButtonHideUnderline,但不适用于DropdownButtonFormField。我想要使用inputDecoration获得的DropdownButtonFormField,但是当我更改项目时,这段代码在运行时会失败。
我要么需要修复它才能运行DropdownButtonFormField,要么我应该找到一种将inputDecoration添加到DropdownButtonHideUnderline中的方法;
在运行时,出现的错误是:
Either zero or 2 or more [DropdownMenuItem]s were detected
我有一个问题,如何将所有数据保存在从主列表中创建的子列表中?我创建了简单的代码来解释我正在寻找的东西。我设法保存了一个值-- swimmer.nameModel,但我需要所有这些值。有什么好的教程来正确地学习这门学科吗?提前谢谢。这是我的代码:
import 'package:flutter/material.dart';
class ModelUser {
final String nameModel;
final String surnameModel;
final String? imageModel;
final String? mobileModel