passo_mobile_app/lib/sevices/passo/unit_construct_services.dart

22 lines
711 B
Dart
Raw Normal View History

2023-07-28 02:35:36 +00:00
import 'dart:convert';
import 'package:unit2/model/passo/unit_construct.dart';
import 'package:http/http.dart' as http;
class UnitConstructService {
static final UnitConstructService _instance = UnitConstructService();
static UnitConstructService get instance => _instance;
Future<List<UnitConstruct>> getUnitConstruct() async {
http.Response response = await http.get(Uri.parse(
'http://192.168.10.218:8000/api/rptass_app/unitconstruct_values/'));
if (response.statusCode == 200) {
final List result = jsonDecode(response.body)['data'];
return result.map(((e) => UnitConstruct.fromJson(e))).toList();
} else {
throw Exception(response.reasonPhrase);
}
}
}