ba75ce8d6d
- removed obsolete deps - fixed many issues - improved features - added: * favourites * account console * push notifications * background sync * improved settings
23 lines
847 B
Dart
23 lines
847 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
Future<String> getCachedTimetable(String ext, String? presetClassNum) async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
String classNum;
|
|
if (presetClassNum != null) {
|
|
classNum = presetClassNum.replaceAll("/", "_");
|
|
} else if (prefs.getString('class_num') != null) {
|
|
classNum = prefs.getString('class_num')!.replaceAll("/", "_");
|
|
} else {
|
|
classNum = '05_1';
|
|
}
|
|
var apiKey = prefs.getString('api_key');
|
|
var headers = {"x-api-key": "$apiKey"};
|
|
var file = await DefaultCacheManager().getSingleFile(
|
|
"https://mein.cantorgymnasium.de/api/timetable/$ext/$classNum",
|
|
headers: headers);
|
|
return (utf8.decode(await file.readAsBytes()));
|
|
}
|