The argument type 'Map Function()' can't be assigned to the parameter type 'Map'

后端 未结 4 1134
梦谈多话
梦谈多话 2021-01-05 03:02

This could initially was working but after firebase update, it is now giving me this error. I have added asterisks to the part giving the error. The error message has been

4条回答
  •  囚心锁ツ
    2021-01-05 03:48

    Apparently all that was needed was parentheses on the maps

    import 'package:cloud_firestore/cloud_firestore.dart';
    
    class Record {
      final String name;
      final int votes;
      final DocumentReference reference;
    
      Record.fromMap(Map map(), {this.reference})
          : assert(map()['name'] != null),
            assert(map()['votes'] != null),
            name = map()['name'],
            votes = map()['votes'];
    
      Record.fromSnapshot(DocumentSnapshot snapshot)
          : this.fromMap(snapshot.data, reference: snapshot.reference);
    
      @override
      String toString() => "Record<$name:$votes>";
    }
    
    

提交回复
热议问题