Good day and thank your for reading the post, I am new to FlutterFlow and i need some help understanding custom Functions. I am trying to create a custom function using the Co-Pilot, where I can display the current day of the week, along with the current date in a text field. However I can't seem to get it right as I dont really know what I am doing.
I added 2 arguments along with the code, 1 for the date and 1 for the day of the week. Argument for date was set to "DateTime" and the argument for day of the week was set to string.
I generated the code with the co-pilot after creating the title and setting the arguments as recommended on YouTube. Would anyone care to explain and help me out with this?Here is the code I got from the co-pilot:
import 'dart:convert';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:timeago/timeago.dart' as timeago;
import '/flutter_flow/lat_lng.dart';
import '/flutter_flow/place.dart';
import '/flutter_flow/uploaded_file.dart';
import '/flutter_flow/custom_functions.dart';
String dayOfWeekAndCurrentDate(
DateTime? date,
String? dayOfWeek,
) {
/// MODIFY CODE ONLY BELOW THIS LINE
// Display current day of week and current date
if (date == null || dayOfWeek == null) {
// If either parameter is null, return an empty string
return '';
} else {
// Format the date and combine it with the day of week
String formattedDate = DateFormat('MMMM d, y').format(date);
return '$dayOfWeek, $formattedDate';
}