我正在尝试从 flutter 中的 API 获取 TimeZones 但由于某种原因它没有返回所有 timeZones
I am trying to get TimeZones from an API in flutter but due to some reason its not returning all timeZones
我是 flutter 框架的新手。我正在尝试从 flutter 中的 API 获取时区,但由于某种原因,它没有返回所有时区。 URL 我试图从中获得回复的是:https://www.timeapi.io/api/TimeZone/AvailableTimeZones
这是我的代码:
import 'package:http/http.dart';
import 'dart:convert';
class WorldClock {
late String location;
late String time;
late String flag;
late String url;
late bool isDayTime = false;
WorldClock({required this.location, required this.flag, required this.url});
Future<void> getLocations() async {
try {
Response response = await get(
Uri.parse('https://www.timeapi.io/api/TimeZone/AvailableTimeZones'));
print(response.body);
} catch (e) {
print('failed to load locations');
}
}
我得到的输出是:
["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmara","Africa/Asmera","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville ","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar", "Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone"," =56=]","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka ","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia", "Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Timbuktu","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Ar
从输出中可以清楚的看到Ameria/Ar之后是breaking而不是存储
任何可能的解决方法?
每个 ide 都有最大控制台日志限制,您可以更改这些限制。
如果您使用的是 IntelliJ 或 Android Studio IDE,请遵循以下 link;
或使用 VSCode 按照以下 link;
我是 flutter 框架的新手。我正在尝试从 flutter 中的 API 获取时区,但由于某种原因,它没有返回所有时区。 URL 我试图从中获得回复的是:https://www.timeapi.io/api/TimeZone/AvailableTimeZones
这是我的代码:
import 'package:http/http.dart';
import 'dart:convert';
class WorldClock {
late String location;
late String time;
late String flag;
late String url;
late bool isDayTime = false;
WorldClock({required this.location, required this.flag, required this.url});
Future<void> getLocations() async {
try {
Response response = await get(
Uri.parse('https://www.timeapi.io/api/TimeZone/AvailableTimeZones'));
print(response.body);
} catch (e) {
print('failed to load locations');
}
}
我得到的输出是:
["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmara","Africa/Asmera","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville ","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar", "Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone"," =56=]","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka ","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia", "Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Timbuktu","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Ar
从输出中可以清楚的看到Ameria/Ar之后是breaking而不是存储
任何可能的解决方法?
每个 ide 都有最大控制台日志限制,您可以更改这些限制。
如果您使用的是 IntelliJ 或 Android Studio IDE,请遵循以下 link;
或使用 VSCode 按照以下 link;