Relative Content

Tag Archive for flutterdartdevelopment-environment

In flutter ternary operator is not working properly?

Code snippet 1:
factory Weather.fromJson(Map<String, dynamic> json) {
return Weather(
sunrise: json[‘daily’][‘sunrise’][0].split(‘T’)[1],
sunset: json[‘daily’][‘sunset’][0].split(‘T’)[1],
temp: json[‘current’][‘temperature_2m’].toString(),
wind: json[‘current’][‘wind_speed_10m’].toString(),
day: json[‘current’][‘is_day’] ? ‘Morning’ : ‘Night’,
time: json[‘current’][‘time’].split(‘T’)[1],
);
}