Skip to content

Flutter and cloud_firestore - is not a subtype of type #15007

Description

@defaultbr

Steps to Reproduce

import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import './Screens/home.dart';



Future query() async {
  DocumentSnapshot result = await Firestore.instance.collection('dummydocs').document("doc1").get();
  print("RESULT: " + result.data.toString());
}

void main() {
  query();
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      home: new Home(title:"Nothing Special"),
    );
  }
}

Logs

03-01 00:24:42.975 7906-7926/com.project E/flutter: [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
    type '_InternalLinkedHashMap' is not a subtype of type 'Map<String, dynamic>' where
      _InternalLinkedHashMap is from dart:collection
      Map is from dart:core
      String is from dart:core
    
    #0      DocumentReference.get (file:///home/tarcisio/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.2.9/lib/src/document_reference.dart)
    <asynchronous suspension>
    #1      query (file:///home/tarcisio/AndroidStudioProjects/test_flutter/lib/main.dart:10:87)
    <asynchronous suspension>
    #2      main (file:///home/tarcisio/AndroidStudioProjects/test_flutter/lib/main.dart:15:3)
    #3      _startIsolate.<anonymous closure> (dart:isolate/isolate_patch.dart:279:19)
    #4      _RawReceivePortImpl._handleMessage (dart:isolate/isolate_patch.dart:165:12)

Run flutter analyze and attach any output of that command also.

Flutter Doctor

-> No Issues found!

Activity

  1. changed the title [-]Flutter and cloud_firestore[/-] [+]Flutter and cloud_firestore - is not a subtype of type[/+] on Mar 1, 2018
  2. Purus commented on Mar 1, 2018

    @Purus

    Sharing what kind of fields are defined in the collection/document will help the team to debug. There are some types which are not supported yet.

  3. Purus commented on Mar 1, 2018

    @Purus

    Could be a duplicate of #11799

  4. cbracken commented on Mar 1, 2018

    @cbracken
    Member
  5. defaultbr commented on Mar 1, 2018

    @defaultbr
    Author

    @Purus

    i did another collection to test and same error:

    - Collection ("example")
    -- Document (''test")
    --- field: "field_text"
    
        DocumentSnapshot result = await Firestore.instance.collection('example')
            .document("test")
        .get();
    

    same error in emulator and real device(with all the playservices ok)

    and keep the same error

  6. defaultbr commented on Mar 2, 2018

    @defaultbr
    Author

    solved in version 0.2.10 (i was using 0.2.9)

    changes -> flutter-team-archive/plugins@915e260

    thanks guys =) that was fast

  7. jmrboosties commented on May 9, 2018

    @jmrboosties

    Still getting this issue on a recent version of flutter:

    Flutter 0.3.6 • channel dev • https://github.com/flutter/flutter.git
    Framework • revision be09a20 (4 days ago) • 2018-05-04 10:31:53 -0700
    Engine • revision e976be1
    Tools • Dart 2.0.0-dev.53.0.flutter-e6d7d67f4b

    specifically when i try to utilize the json_serializable (https://pub.dartlang.org/packages/json_serializable) package to convert a record from Firebase to an object in Dart.

  8. asoseil commented on May 18, 2018

    @asoseil

    same problem, is there any workaround?

  9. jmrboosties commented on May 27, 2018

    @jmrboosties

    Sorry for the late response, I had avoided this issue and worked on some other stuff in the project for a while. I think I figured out a fix, but it's extremely goofy...

    Map<String, dynamic> mapJson = document.data;
    new MyObject.fromJson(json.decode(json.encode(mapJson))));

    ¯\(ツ)/¯

  10. brilliant-ember commented on Nov 29, 2018

    @brilliant-ember

    I used this approach

    if(json["key"]!= null){ this.active_guests = json["key"].cast<String, int>(); }
    it works fine you just have to cast it to the proper types you want. I think this issue can be closed

  11. kroikie commented on Oct 13, 2019

    @kroikie

    @defaultbr

    This issue has been moved to firebase/flutterfire#899. Any further collaboration will be done there.

  12. github-actions commented on Aug 27, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p: firebaseObsolete - Firebase plugins

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions