Custom calendar widget - unable to process parameter onDateSelected

Here is my code for a custom calendar widget. I am getting an error: "Unable to process parameter "onDateSelected".

Are you sure you want to save?". Can anyone please help me how to get rid of this error? Thank you...

// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/custom_code/actions/index.dart'; // Imports custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!


import 'package:table_calendar/table_calendar.dart';
import 'dart:math';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FlutterFlow Calendar',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late DateTime _selectedDate;
  late DateTime _randomDate;

  @override
  void initState() {
    super.initState();
    _selectedDate = DateTime.now(); // Initialize selectedDate with today's date
    _randomDate = _generateRandomDate(_selectedDate); // Generate random date for the current week
  }

  DateTime _generateRandomDate(DateTime selectedDate) {
    DateTime firstDayOfWeek = selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
    DateTime lastDayOfWeek = selectedDate.add(Duration(days: DateTime.daysPerWeek - selectedDate.weekday));
    int weekDifference = lastDayOfWeek.difference(firstDayOfWeek).inDays;
    int randomOffset = Random().nextInt(weekDifference + 1);
    return firstDayOfWeek.add(Duration(days: randomOffset));
  }

  void _onDateSelected(DateTime selectedDay, DateTime focusedDay) {
    setState(() {
      _selectedDate = selectedDay;
      _randomDate = _generateRandomDate(focusedDay);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('FlutterFlow Calendar'),
      ),
      body: Column(
        children: <Widget>[
          CustomCalendar(
            selectedDate: _selectedDate,
            onDateSelected: _onDateSelected,
          ),
          SizedBox(height: 20),
          Text(
            'Randomly selected date: ${_randomDate.toString()}',
            style: TextStyle(fontSize: 18),
          ),
        ],
      ),
    );
  }
}

class CustomCalendar extends StatefulWidget {
  final DateTime selectedDate;
  final Function(DateTime, DateTime) onDateSelected;

  const CustomCalendar({
    required this.selectedDate,
    required this.onDateSelected,
    Key? key,
  }) : super(key: key);

  @override
  State<CustomCalendar> createState() => _CustomCalendarState();
}

class _CustomCalendarState extends State<CustomCalendar> {
  late DateTime _focusedDay;

  @override
  void initState() {
    super.initState();
    _focusedDay = widget.selectedDate;
  }

  @override
  Widget build(BuildContext context) {
    return TableCalendar(
      firstDay: DateTime.utc(2020, 1, 1),
      lastDay: DateTime.utc(2030, 12, 31),
      focusedDay: _focusedDay,
      selectedDayPredicate: (day) => isSameDay(widget.selectedDate, day),
      onDaySelected: (selectedDay, focusedDay) {
        widget.onDateSelected(selectedDay, focusedDay);
      },
      onPageChanged: (focusedDay) {
        setState(() {
          _focusedDay = focusedDay;
        });
      },
    );
  }
}
1