Problem converting app to null safety

95 views
Skip to first unread message

jerry hamby

unread,
May 31, 2021, 4:54:35 PM5/31/21
to Flutter Development (flutter-dev)

I just have one issue left and I can’t find an answer anywhere.

——— problem code ——— snapshot.data has a red line

The argument type 'Object? Function()' can't be assigned to the parameter type 'Map<String, dynamic>'.


Record.fromMap(Map<String, dynamic> map, {required this.reference})

      : assert(map['firstname'] != null),

        assert(map['accountid'] != null),

        firstname = map['firstname'].toLowerCase(),

        accountid = map['accountid'];


  Record.fromSnapshot(DocumentSnapshot snapshot)

      : this.fromMap(snapshot.data, reference: snapshot.reference);


I’m looking for links or sample code. 

PS- this code worked before null safety

Suzuki Tomohiro

unread,
May 31, 2021, 5:09:35 PM5/31/21
to jerry hamby, Flutter Development (flutter-dev)
Does the error message make sense to you?

If not, can you check the followings:
- What’s the data type of snapshot.data?
- What’s the data type this.fromMap takes?


--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/0d5b34e1-7061-47b2-bc47-d01423fb3d11n%40googlegroups.com.

jerry hamby

unread,
Jun 1, 2021, 7:32:29 PM6/1/21
to Flutter Development (flutter-dev)
After looking deeper in the problem, the class and page that required this fix is not used
by my app, so I deleted both of them which fixed the issue. Still don’t understand the issue, but one
problem solved.

I think this code got into my app very early in my learning process, null safety just exposed the issue.

wa...@clinicianfirst.com

unread,
Jun 2, 2021, 7:57:17 PM6/2/21
to Flutter Development (flutter-dev)
For those seeing this problem,  who can't delete the offending pages, see this migration guide:

This helped me work through my issues.
Reply all
Reply to author
Forward
0 new messages