0
I’m trying to do a validation on Dart, where my function timevalider()
has a variable of type dynamic
, where he fits in with what I put in.
I’m doing the following assignment time = new DateTime.now().toIso8601String()
, because with this I take the current time of my computer, which is returned, by exmeplo:
2020-04-03T16:05:29.620
I made a condition where returns me the text "Bomdia", case the time
is less than and equal to 6.
But when I run it appears this message:
How could I fix this mistake, I’m floating in something? There’s a way to do it in a different way, you could help me build it?
Follows the Code:
class Personagem{
String nome;
String povoado;
int level;
String classe;
String habilidade;
void levelskill(){
level++;
}
//Só para assinantes
void levelskillx4(){
level +=4;
}
void renascer(){
print("$nome morreu e renasceu no altar");
}
void death(){
print("Você morreu! você perdeu uma porcentagem de level");
level--;
print("$level");
}
//Só para assinantes
void premium(){
print("Parabens $nome, agora você é premium, você tem 31 Dias.");
}
void timevalider(){
dynamic time = (new DateTime.now().toIso8601String());
if( time <= 6 || time <= 13){
print("Morning");
} else if (time >= 13 || time <19){
print("Good Afternoon");
} else print("Good Night");
}
}
void main(){
Personagem pessoa1 = Personagem();
pessoa1.nome = "testeper";
pessoa1.povoado = "canada";
pessoa1.level = 5;
pessoa1.classe = "mago";
pessoa1.habilidade = "Magia e Controle";
print(pessoa1.nome);
print(pessoa1.povoado);
print(pessoa1.level);
print(pessoa1.classe);
print(pessoa1.habilidade);
pessoa1.premium();
pessoa1.timevalider();
print(new DateTime.now().toIso8601String());
}
It worked out I don’t even know how to thank, what would be this function "final" ??
– LordDual
But again thank you, now I understand my grotesque mistake, I’m enjoying the language as a whole, see excuse can I just ask you one more thing? it is possible to have input functions in Dart? type an equal language scanf c
– LordDual