e86c1bad1d
- code cleanup - caching - black-/whitelist - sz/news fixes - added settings options ...
21 lines
732 B
Dart
21 lines
732 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) async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
String classNum;
|
|
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()));
|
|
}
|