I really don't get it. "twoMark" and "twoTente" are null so I made an If/else statement to convert them into 0 if they are indeed null or if not, just int.parse the value... but the code just IGNORE the IF and go straight to the else even tho the value is null so it is supposed to stop after it.
SO i get this error: Unhandled Exception: FormatException: Invalid radix-10 number (at character 1).
Because for my understanding he is trying to do the "twoMark = int.parse(twoMark ??= '0');" instead of stopping at "twoMark = int.parse(twoMark == null ? twoMark : '0');"
if(twoMark == null){
print("FGM EST NULLE");
twoMark = int.parse(twoMark == null ? twoMark : '0');
}else{
print(" FGM N'EST PAS NULLE");
twoMark = int.parse(twoMark ??= '0');
}
my console is printing the second print even tho "twoMark" IS NULL.
----------- FULL CODE ---------
avePicture(pathing, idTeamPlayer, fPlayerName, lPlayerName, phonePlayer, age,
taille, jerNumb, position, fgm, fga, context) async {
SharedPreferences sp = await _pref;
final statAccess = DatabaseModel();
int? idPlayer = sp.getInt("idPlayer");
idTeamPlayer = sp.getInt("idTeam");
phonePlayer = phonePlayer.replaceAll(RegExp('[^0-9]'), '');
fPlayerName = fPlayerName.replaceAll(RegExp('[^A-Za-z]'), '');
lPlayerName = lPlayerName.replaceAll(RegExp('[^A-Za-z]'), '');
var twoTente = fga;
var twoMark = fgm;
if(jerNumb != null){
jerNumb = jerNumb.replaceAll(RegExp('[^0-9]'), '');
}
twoMark ??= '0';
final intTwooMark = int.parse(twoMark);
print("THE TWO $intTwooMark");
int.parse(twoMark == null ? twoMark : '0')is backwards. IftwoMarkisnull, you're callingint.parse(null). ThetwoMark == nullcheck is redundant anyway since you already checked it in the outerif.