22 lines
711 B
Dart
22 lines
711 B
Dart
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|