How does one convert data in API Weather – Sunrise/Sunset in flutter?

Issue

How do I convert sunset/sunrise data into time in flutter

{"type":1,"id":9052,"country":"IN","sunrise":1628470082,"sunset":1628516419},"timezone":19800

How do I convert this data in here: Map setrise = data[‘sys’];

Map setrise = data['sys'];
 int getsunrise = setrise['sunrise'];
  int getsunset = setrise['sunset'];

  //getting timezone
  int getTimezone = data['timezone'];

Where ‘data’ is Map of response of API

Solution

Try this code

DateTime.fromMillisecondsSinceEpoch(apisunsettime * 1000),

Answered By – Said Kurt

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *