0

i am new to FF and when i compile my code, i received the following error.

The method 'CustomCalendar' isn't defined for the type '_MyCalendarState'. Try correcting the name to the name of an existing method, or defining a method named 'CustomCalendar'.

// Automatic FlutterFlow imports
import '/backend/backend.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 '/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:flutterflow_widgets/flutterflow_widgets.dart';

class MyCalendar extends StatefulWidget {
  const MyCalendar({
    Key? key,
    this.width,
    this.height,
    required this.collectionName,
    required this.onTap,
  }) : super(key: key);

  final double? width;
  final double? height;
  final String collectionName;
  final Future<dynamic> Function() onTap;

  @override
  _MyCalendarState createState() => _MyCalendarState();
}

class _MyCalendarState extends State<MyCalendar> {
  final Map<DateTime, dynamic> events = {};

  @override
  void initState() {
    super.initState();
    init();
  }

  init() async {
    // / Get documents from collection
    FirebaseFirestore.instance
        .collection(widget.collectionName)
        .snapshots()
        .listen((QuerySnapshot querySnapshot) {
      if (querySnapshot.size == 0 || querySnapshot.docs.isEmpty) {
        return;
      }
      events.clear();
      for (final doc in querySnapshot.docs) {
        if (doc['date'] == null) continue;
        final data = doc.data() as Map<String, dynamic>;
        data['reference'] = doc.reference;
        events[doc['date'].toDate()] = data;
      }
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return CustomCalendar(
      events: events,
      onDaySelected: (events) {
        print('events; $events');
        FFAppState().events = events ?? [];
        widget.onTap();
      },
    );
  }
}

Please help to see what is wrong with the code. Thanks

RBR
  • 1

0 Answers0