Commit 5604bdce authored by wonko's avatar wonko

pre-filling the cache

parent fc1e858c
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.prause.night_of_science">
package="de.prause.nos">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.prause.night_of_science">
package="de.prause.nos">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
......
This diff is collapsed.
......@@ -26,6 +26,8 @@ class LectureData extends Assets {
factory LectureData() => _instance;
Lectures _data;
Lectures get data {
......@@ -44,13 +46,17 @@ class LectureData extends Assets {
}
Future<Lectures> _getData() async {
FileInfo finfo = await DefaultCacheManager()
.getFileFromCache('https://nos.prause.de/lectureees.json');
print(finfo);
File file = await DefaultCacheManager()
.getSingleFile('https://nos.prause.de/lectures.json');
//uString dataAsString = await rootBundle.loadString(file);
final DefaultCacheManager dcm = DefaultCacheManager();
final String lurl = 'https://nos.prause.de/lttectures.json';
FileInfo finfo = await dcm.getFileFromCache(lurl);
if (finfo == null){
//preload from assets
var bytes = await rootBundle.load('assets/data/lectures.json');
dcm.putFile(lurl, bytes.buffer.asUint8List());
finfo = await dcm.getFileFromCache(lurl);
}
File file = finfo.file;
String dataAsString = await file.readAsString();
Map<String, dynamic> json = await jsonDecode(dataAsString);
return Future(() {
......
......@@ -12,7 +12,7 @@ class ScheduleWidget extends StatefulWidget {
class _ScheduleWidgetState extends State<ScheduleWidget>
with SingleTickerProviderStateMixin {
TabController _tabController;
//TabController _tabController;
ScrollController _scheduleScrollController;
ScrollController _timeScaleScrollController = new ScrollController();
final LectureData lectureData = LectureData();
......@@ -26,7 +26,7 @@ class _ScheduleWidgetState extends State<ScheduleWidget>
@override
void dispose() {
_tabController.dispose();
//_tabController.dispose();
super.dispose();
}
......@@ -57,7 +57,6 @@ class _ScheduleWidgetState extends State<ScheduleWidget>
List<Widget> roomViews() {
List<Widget> rv = [];
for (Room room in lectureData.data.rooms) {
print(room);
rv.add(RoomSchedule(_scheduleScrollController, room));
}
return rv;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment