22 lines
718 B
Dart
22 lines
718 B
Dart
|
import 'dart:convert';
|
||
|
|
||
|
import 'package:unit2/model/passo/class_components.dart';
|
||
|
import 'package:http/http.dart' as http;
|
||
|
|
||
|
class ClassComponentService {
|
||
|
static final ClassComponentService _instance = ClassComponentService();
|
||
|
static ClassComponentService get instance => _instance;
|
||
|
|
||
|
Future<List<ClassComponents>> getClassComponent() async {
|
||
|
http.Response response = await http.get(Uri.parse(
|
||
|
'http://192.168.10.218:8000/api/rptass_app/class_components/'));
|
||
|
if (response.statusCode == 200) {
|
||
|
final List result = jsonDecode(response.body)['data'];
|
||
|
|
||
|
return result.map(((e) => ClassComponents.fromJson(e))).toList();
|
||
|
} else {
|
||
|
throw Exception(response.reasonPhrase);
|
||
|
}
|
||
|
}
|
||
|
}
|