// Automatic FlutterFlow imports import '/backend/schema/structs/index.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'index.dart'; // Imports other custom actions import '/flutter_flow/custom_functions.dart'; // Imports custom functions import 'package:flutter/material.dart'; // Begin custom action code // DO NOT REMOVE OR MODIFY THE CODE ABOVE! // Set your action name, define your arguments and return parameter, // and then add the boilerplate code using the `` button on the right! import 'package:add_2_calendar/add_2_calendar.dart'; Future zetInAgenda(String titel, String startIso, String? eindIso, String? locatie, String? omschrijving, String? plaats, String? nid) async { DateTime? start = DateTime.tryParse(startIso.trim().replaceFirst(' ', 'T')); if (start == null) { return false; } DateTime? eind; if (eindIso != null && eindIso.trim().isNotEmpty) { eind = DateTime.tryParse(eindIso.trim().replaceFirst(' ', 'T')); } if (eind == null || !eind.isAfter(start)) { eind = start.add(Duration(hours: 2)); } String tekst = omschrijving ?? ''; tekst = tekst.replaceAll(RegExp(r'<[^>]*>'), ' '); tekst = tekst.replaceAll(' ', ' '); tekst = tekst.replaceAll('&', '&'); tekst = tekst.replaceAll(RegExp(r'\s+'), ' ').trim(); if (tekst.length > 500) { tekst = tekst.substring(0, 500) + '...'; } String naam = titel.trim(); if (naam.isEmpty) { naam = 'Evenement'; } String link = (nid ?? '').trim(); if (link.isNotEmpty) { tekst = 'https://uitgk.com/' + link + '\n\n' + tekst; } eind = start; if ((locatie ?? '').trim().isEmpty) { locatie = (plaats ?? '').trim(); } else if ((plaats ?? '').trim().isNotEmpty) { locatie = (locatie ?? '').trim() + ', ' + (plaats ?? '').trim(); } try { return await Add2Calendar.addEvent2Cal(Event( title: naam, description: tekst, location: (locatie ?? '').trim(), startDate: start, endDate: eind)); } catch (e) { return false; } }