title: Undefined name 'contact' - Flutter toJson Map in Stateful widget
body: <p>I've created a map yet am having difficulty accessing the variable 'contact' within a stateful widget. I'm not sure where else to declare <code>final Contact contact; </code>.</p>
  <p>The Contact model file.</p>
  <pre><code>class Contact {
  int rating;
  String name;
  String location;
  int phoneNumber;
  String instagram;
  int birthday;
  String notes;
  
  Contact(this.name, this.phoneNumber, this.location, this.rating,
  this.instagram, this.birthday, this.notes);
  
  Map&lt;String, dynamic&gt; toJson() =&gt; {
      'Name': name,
      'PhoneNumber': phoneNumber,
      'Location': location,
      'Rating': rating,
      'Instagram': instagram,
      'Birthday': birthday,
      'Notes': notes,
    };
  </code></pre>
  <p>Where <code>final Contact contact; </code> is currently declared</p>
  <pre><code>class NewContact extends StatefulWidget {
  NewContact({Key key, @required this.contact}) : super(key: key);
  final Contact contact;
  
  @override
  NewContactState createState() =&gt; NewContactState();
  }
  
  class NewContactState&lt;T extends NewContact&gt; extends State&lt;T&gt; {
  final db = FirebaseFirestore.instance; //...etc
  </code></pre>
  <p>Where the Map is being called</p>
  <pre><code> await db
                    .collection(&quot;userData&quot;)
                    .doc(uid)
                    .collection(&quot;Contacts&quot;)
                    .add(contact.toJson());
  </code></pre>
  <p>Error = Undefined name 'contact'.</p>