
I have 10 attributes in my collection and when I run the application it gives an error at this point:
databases ?? init();
try {
String userId = await AuthHelper.instance.getUserId() ?? "";
DocumentList response = await databases!.listDocuments(
databaseId: "64046c8b50eba8c807d0",
collectionId: "6405162fd68c7c61df67",
);
return response.documents
.map(
(e) => TodoModel.fromJson(e.data, e.$id,)
)
.toList();
} catch (e) {
rethrow;
}
}```
Exception has occurred.
_TypeError (type 'Null' is not a subtype of type 'String')
This is what my data model looks like:
class TodoModel { String name; int scores; double progress; List<dynamic> errors; List<dynamic> friends; int alchiki; String refcode; DateTime createdAt; String id; String userId;
TodoModel({ required this.name, required this.scores, required this.progress, required this.errors, required this.friends, required this.alchiki, required this.refcode, required this.createdAt, required this.userId, required this.id, });
TodoModel.fromJson(Map<String, dynamic> json, String tempId) : name = json['first_name'], scores = json['scores'], progress = json['progress'], errors = json['errors'], friends = json['friends'], alchiki = json['alchiki'], refcode = json['refcode'], createdAt = DateTime.parse(json['createdAt']), userId = json['userId'], id = tempId;
Map<String, dynamic> toJson() => { 'first_name': name, 'scores': scores, 'progress': progress, 'errors': errors, 'friends': friends, 'alchiki': alchiki, 'refcode': refcode, 'createdAt': createdAt.toIso8601String(), 'userId': userId, }; } ```

If I remove the "refcode" attribute from the model, then the application will work fine.

it seems you have a document where refcode
is null
, right?

SOLVED

[SOLVED] Null is not a subtype
Recommended threads
- Flutter OAuth2 Google does not return to...
When the flow starts, the browser opens, I select an account, and it keeps showing: """ Page not found The page you're looking for doesn't exist. `general_rout...
- Redirect URL sends HTTP instead of HTTPS...
I am not sure since when this issue is present, but my Google and Apple redirect URI are no longer pointing to the HTTPS redirect URI when I try to use OAuth. ...
- Failing to run document operations on sd...
Could someone point me in the right direction I'm going in cirlces. I have a problem with sdks and my self-hosted server in production (for ~3 years) I have bee...
