Files
rog_app/lib/services/perfecture_service.dart
Mohamed Nouffer ee3845681d update
2022-03-30 16:19:18 +05:30

42 lines
989 B
Dart

import 'dart:convert';
import 'package:http/http.dart' as http;
class PerfectureService{
static Future<List<dynamic>?> loadPerfectures() async {
List<dynamic> perfs = [];
String url = 'http://localhost:8100/api/perf_main/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
perfs = json.decode(utf8.decode(response.bodyBytes));
}
return perfs;
}
static Future<List<dynamic>?> loadSubPerfectures(String sub) async {
List<dynamic> perfs = [];
String url = 'http://localhost:8100/api/insubperf/?perf=' + sub;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
perfs = json.decode(utf8.decode(response.bodyBytes));
}
return perfs;
}
}