birthday property Null safety

DateTime? birthday

Implementation

DateTime? get birthday {
  if (_userData.containsKey('birthday')) {
    var birthdayMap = _userData['birthday'] as Map<String, int>;
    return DateTime(
        birthdayMap['year']!, birthdayMap['month']!, birthdayMap['day']!);
  }
  return null;
}
void birthday=(DateTime? date)

Implementation

set birthday(DateTime? date) {
  if (date != null) {
    var birthdayMap = <String, int>{
      'year': date.year,
      'month': date.month,
      'day': date.day,
    };
    _userData['birthday'] = birthdayMap;
  } else {
    _userData.remove('birthday');
  }
  _updateInstance(_userData);
}