passo_mobile_app/lib/sevices/passo/class_components_services.dart

22 lines
718 B
Dart
Raw Normal View History

2023-07-28 02:35:36 +00:00
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);
}
}
}