Valor padrão em atributo de Class #44
Answered
by
DouglasValerio
John-Rocha
asked this question in
Perguntas e Respostas
-
Bom dia galera. Eu estou com uma dúvida com relação à declaração de um valor default em um atributo de uma class. Tenho a seguinte class: class WorkerCommunication {
final bool? agree;
DateTime? agreeDate;
WorkerCommunication({
this.agree,
this.agreeDate,
});
} Daí eu preciso que o atributo Alguma sugestão? |
Beta Was this translation helpful? Give feedback.
Answered by
DouglasValerio
Sep 29, 2022
Replies: 1 comment 2 replies
-
Opa, class WorkerCommunication {
final bool? agree;
DateTime? agreeDate;
WorkerCommunication({
this.agree,
DateTime? agreeDate
}): agreeDate = agreeDate ?? DateTime.now();
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
John-Rocha
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Opa,
Creio que você possa fazer dessa forma aqui: