Closed
Description
If I use "??=" dart analyzer don't understand that variable can not be null.
Example:
static void regCommand(String command, Function action, {bool? isMustRemove}) {
teleDart.onCommand(command).listen((message) {
isMustRemove ??= false;
if (isMustRemove) {
teleDart.deleteMessage(message.chat.id, message.message_id);
}
});
}
But in reality isMustRemove can not be null. Of course, if I use {bool isMustRemove = false} is solve this case, but we have more cases with analyze null.
And if I write:
static void regCommand(String command, Function action, {bool? isMustRemove}) {
teleDart.onCommand(command).listen((message) {
isMustRemove ??= false;
if(isMustRemove != null) {
if (isMustRemove) {
teleDart.deleteMessage(message.chat.id, message.message_id);
}
}
});
}
or
static void regCommand(String command, Function action, {bool? isMustRemove}) {
teleDart.onCommand(command).listen((message) {
isMustRemove ??= false;
if (isMustRemove as bool) {
teleDart.deleteMessage(message.chat.id, message.message_id);
}
});
}
all work.