http플러그인을 이용해 값을 가져올 것이며,
위도,경도 가져오기와 플러그인 사용에 대해 중복으로 설명하진 않겠습니다:)
https://www.openuv.io/
자외선 지수를 무료로 제공해주는 오픈소스 API
가입 > 메일확인 > API Key 전달받음
https://www.openuv.io/uvindex
테스트 가능
final _openUVkey = '3d58발급받으세요cf';
Future<void> getUVData({
String lat,
String lon,
}) async {
var nowDate = DateTime.now().toString();
var str = 'https://api.openuv.io/api/v1/uv?lat=$lat&lng=$lon&dt=$nowDate';
print(str);
var response = await http.get(str, headers: {'x-access-token': _openUVkey});
if (response.statusCode == 200) {
var data = response.body;
print('uv data = $data');
} else {
print('response status code = ${response.statusCode}');
}
}
{
"result": {
"uv": 0,
"uv_time": "2020-06-18T14:22:51.647Z",
"uv_max": 9.6583,
"uv_max_time": "2020-06-18T03:34:18.414Z",
"ozone": 332.8,
"ozone_time": "2020-06-18T03:07:06.807Z",
"safe_exposure_time": {
"st1": null,
"st2": null,
"st3": null,
"st4": null,
"st5": null,
"st6": null
},
"sun_info": {
"sun_times": {
"solarNoon": "2020-06-18T03:34:18.414Z",
"nadir": "2020-06-17T15:34:18.414Z",
"sunrise": "2020-06-17T20:11:50.327Z",
"sunset": "2020-06-18T10:56:46.500Z",
"sunriseEnd": "2020-06-17T20:14:57.564Z",
"sunsetStart": "2020-06-18T10:53:39.264Z",
"dawn": "2020-06-17T19:40:40.897Z",
"dusk": "2020-06-18T11:27:55.930Z",
"nauticalDawn": "2020-06-17T19:01:42.496Z",
"nauticalDusk": "2020-06-18T12:06:54.331Z",
"nightEnd": "2020-06-17T18:17:39.032Z",
"night": "2020-06-18T12:50:57.795Z",
"goldenHourEnd": "2020-06-17T20:50:49.598Z",
"goldenHour": "2020-06-18T10:17:47.230Z"
},
"sun_position": {
"azimuth": 2.8239582691770235,
"altitude": -0.4687033211142961
}
}
}
}
var data = response.body;
var jsonData = jsonDecode(data);
print('uv data = $data');
print('uv max data = ${jsonData['result']['uv_max']}');
https://www.weather.go.kr/weather/lifenindustry/jisudaymap_A07_1.jsp
도움이 되었습니다. 감사합니다!