I wrote the following code but I got the error in the screenshot. I added everything from pub.dev, I only wrote Event class on my own, I am also adding it here. Can you help me on solving?
I am kind of learning these topics recently so my mistake might be really simple but it would be great if you could spend some time on it.
import 'dart:ui';
import 'package:calendar_view/calendar_view.dart';
import 'package:flutter/material.dart';
import 'calendarFiles/model/event.dart';
import 'calendarFiles/pages/mobile/mobile_home_page.dart';
import 'calendarFiles/pages/web/web_home_page.dart';
import 'calendarFiles/widgets/responsive_widget.dart';
DateTime get _now => DateTime.now();
class CalendarScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CalendarControllerProvider<Event>(
controller: EventController<Event>()..addAll(_events),
child: MaterialApp(
title: 'Calendar',
debugShowCheckedModeBanner: false,
theme: ThemeData.light(),
scrollBehavior: ScrollBehavior().copyWith(
dragDevices: {
PointerDeviceKind.trackpad,
PointerDeviceKind.mouse,
PointerDeviceKind.touch,
},
),
home: ResponsiveWidget(
mobileWidget: MobileHomePage(),
webWidget: WebHomePage(),
),
),
);
}
}
List<CalendarEventData<Event>> _events = [
CalendarEventData(
date: _now,
event: Event(title: "Joe's Birthday"),
title: "Project meeting",
description: "Today is project meeting.",
startTime: DateTime(_now.year, _now.month, _now.day, 18, 30),
endTime: DateTime(_now.year, _now.month, _now.day, 22),
),
... more events ...
];
class EventDetailsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Event Details'),
),
body: Center(
child: Text('Event Details Screen'),
),
);
}
}
class Event {
final String title;
final String description;
final DateTime? startTime;
final DateTime? endTime;
Event({
required this.title,
this.description = '',
this.startTime,
this.endTime,
});
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is Event &&
other.title == title &&
other.description == description &&
other.startTime == startTime &&
other.endTime == endTime;
}
@override
int get hashCode {
return title.hashCode ^
description.hashCode ^
startTime.hashCode ^
endTime.hashCode;
}
}
I tried changing Event class but it didn't work.
