Event Though it's printing the Instance of 'Event' I'm unable to access its properties.
itemBuilder: (context, index) {
print(events[index]);
}
Event Class
class Event {
String Date;
String FullDate;
String BookinkStatus;
String BookinkStatusId;
String BookingColorHEX;
String BookingText;
String SecondText;
String OnlyDate;
bool IsFee;
}
console output
Instance of 'Event'
Instance of 'Event'
Instance of 'Event'
If I use the dot operator then it's throwing error. The getter 'Date' isn't defined for the class 'Object'.
itemBuilder: (context, index) {
print(events[index].Date);
}
Full Code
calendarBuilders: CalendarBuilders(
markerBuilder: (BuildContext context, date, events) {
if (events.isEmpty) return SizedBox();
return ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: events.length,
itemBuilder: (context, index) {
print(events[index]!.Date);
return Container(
margin: const EdgeInsets.only(top: 22),
padding: const EdgeInsets.all(1),
child: Container(
// height: 7,
width: 5,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black54)),
);
});
},
),
CodePudding user response:
Please share full code . Unable to understand
CodePudding user response:
For using .dot operator you need to use Constructor
class Event {
String Date;
String FullDate;
String BookinkStatus;
String BookinkStatusId;
String BookingColorHEX;
String BookingText;
String SecondText;
String OnlyDate;
bool IsFee;
}
Event({
this.Date,
this.FullDate,
this.BookinkStatus,
this.BookinkStatusId,
this.BookingColorHEX,
this.BookingText,
this.SecondText,
this.OnlyDate,
this.IsFee,
});