18 lines
559 B
Dart
18 lines
559 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;
|
|
}
|
|
}
|