Created
December 2, 2021 10:40
-
-
Save berkayoruc/0dd2a4989bb2c4506ed68281b4422dad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<List<Buffet>> getBuffets() async { | |
var headers = {'Access-Control-Allow-Origin': '*'}; | |
final response = await http.get(Uri.parse(buffetUrl), headers: headers); | |
return compute(parseBuffets, [response.body]); | |
} | |
List<Buffet> parseBuffets(List<dynamic> arguments) { | |
final body = arguments.elementAt(0); | |
final parsed = jsonDecode(body)['result']['records']; | |
List<Buffet> values = []; | |
if (parsed != null) { | |
values = parsed | |
.map<Buffet>((e) => Buffet( | |
int.parse(e['_id'].toString()), | |
e['Ilce_Adi'], | |
e['Mahalle_Adi'], | |
e['Bufe_Adi'], | |
e['Enlem'], | |
e['Boylam'])) | |
.toList(); | |
} | |
return values; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment