workouttest_util/lib/service/property_service.dart
2023-01-28 12:53:16 +01:00

19 lines
561 B
Dart

import 'dart:convert';
import 'package:workouttest_util/model/cache.dart';
import 'package:workouttest_util/service/api.dart';
import 'package:workouttest_util/model/property.dart';
class PropertyApi {
final APIClient _client = APIClient();
Future<List<Property>> getProperties() async {
final body = await _client.get("property/", "");
final Iterable json = jsonDecode(body);
final List<Property> properties = json.map((property) => Property.fromJson(property)).toList();
Cache().setProperties(properties);
return properties;
}
}