19 lines
490 B
Dart
19 lines
490 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:aitrainer_app/model/cache.dart';
|
|
import 'package:aitrainer_app/service/api.dart';
|
|
|
|
import '../model/sport.dart';
|
|
|
|
class SportApi {
|
|
final APIClient _client = APIClient();
|
|
|
|
Future<List<Sport>> getSports() async {
|
|
final body = await _client.get("sports/", "");
|
|
final Iterable json = jsonDecode(body);
|
|
final List<Sport> sports = json.map((sport) => Sport.fromJson(sport)).toList();
|
|
Cache().setSports(sports);
|
|
return sports;
|
|
}
|
|
}
|