How to initialize Map in a constructor in Dart/Flutter

Viewed 1678

I'm trying to do something like this (code below) but the IDE flags it. Is there any possible way to do this? Thanks.

final Map userInfo;

UserProfile({this.userInfo = {} });
1 Answers

Should be:

class UserProfile {
  final Map userInfo;

  const UserProfile({this.userInfo = const {}});
}
Related