You are trying to parse 5:3
as int which causes the error.
The issue is in the substring that is returning an invalid number (5:3). You should do data['utc_offset'].substring(1,3)
to get only the hour and data['utc_offset'].substring(4,6)
to get only the minutes. After that you can manipulate as you wish, like:
String offsetHours = data['utc_offset'].substring(1, 3);
String offsetMinutes = data['utc_offset'].substring(4, 6);
DateTime now = DateTime.parse(datetime);
now = now.add(Duration(
hours: int.parse(offsetHours),
minutes: int.parse(offsetMinutes)),
);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…