21 lines
762 B
Dart
21 lines
762 B
Dart
import 'package:hiddingsel_app/appflow/model/event_organisations.dart';
|
|
|
|
import '../../../services/network.dart';
|
|
import '../../../todo/parser.dart';
|
|
import '../../model/event.dart';
|
|
import 'package:http/http.dart';
|
|
import 'dart:convert' show utf8;
|
|
|
|
class CalendarController {
|
|
|
|
static Future<List<EventModel>> getOrganisationEvents(EventOrganisationModel eventOrganisation) {
|
|
if(eventOrganisation.ical == null) return Future.value(List<EventModel>.empty());
|
|
return BaseService.getSaveFromServer(
|
|
() => _getEvents(eventOrganisation.ical), List<EventModel>.empty());
|
|
}
|
|
|
|
static Future<List<EventModel>> _getEvents(icalUri) async {
|
|
final response = await get(icalUri);
|
|
return IcalParser.parse(utf8.decode(response.bodyBytes));
|
|
}
|
|
} |