swift – SwiftUI check if UserSettings DOB is default

I am trying to set the date of birth DatePicker to allow a user to set it once and then it becomes locked.

I thought I would do an if statement however apparently DatePicker() does not allow .if()

So I thought I would try the following below.


However I am getting the following issue.

No exact matches in call to initializer
script to check date of birth

Now the default of DOB its set to todays date.

The goal is to make this section

 DatePicker(LocalizedStringKey("Date"),selection: $userSettings.dateofbirth,in: ...Date(),
                               displayedComponents: .date)

be only changed once.