Back

type 'Null' is not a subtype of type 'List<dynamic>' in getDocument Method

  • 0
  • Databases
  • Flutter
Mosh Ontong
12 Jan, 2024, 23:15
TL;DR
Issue: Getting the error 'type 'Null' is not a subtype of type 'List<dynamic>' in getDocument method' when fetching a specific document. Solution: Check if the id being passed is a non-empty string. Inspect the map to see what values are present for 'total' and 'documents'.
Mosh Ontong
12 Jan, 2024, 23:16

why the map value has total and documents object

Mosh Ontong
12 Jan, 2024, 23:17

This my code on fetching the specific document

TypeScript
  @override
  Future<BridgeRequest> getRequest(String id) async {
    try {
      _logger.info('Getting bridge request');

      final response = await databases.getDocument(
        databaseId: bridgeRequestCredential.databaseId,
        collectionId: bridgeRequestCredential.collectionId,
        documentId: id,
      );
      return BridgeRequest.fromJson(response.data);
    } on AppwriteException catch (e, stackTrace) {
      _logger.severe(
          e.message ?? 'Error while getting bridge request', e, stackTrace);
      throw BridgeException(
        message: e.message ?? 'Error while getting bridge request',
        stackTrace: stackTrace,
      );
    } catch (e, stackTrace) {
      _logger.severe('Error while getting bridge request', e, stackTrace);
      throw BridgeException(
        message: 'Error while getting bridge request',
        stackTrace: stackTrace,
      );
    }
  }
Mosh Ontong
12 Jan, 2024, 23:29
Mosh Ontong
12 Jan, 2024, 23:29

I really need help for this one

Drake
13 Jan, 2024, 02:31

Would you please try to inspect the map to see what's in it? nvm

Drake
13 Jan, 2024, 02:31

And please double check you're passing a non empty string for the id

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more