This is the code from a flutter calendar widget that I am currently using:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Calendar"),
),
body: StreamBuilder(
stream: FirebaseFirestore.instance.collection('Events').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return Text('Loading data... Please Wait');
print(snapshot.data.documents['name']);
return Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
_buildTableCalendar(context, snapshot),
const SizedBox(height: 8.0),
Expanded(child: _buildEventList()),
],
);
}));
}
Widget _buildTableCalendar(BuildContext context, AsyncSnapshot snapshot) {
return TableCalendar(
calendarController: _controller,
events: _events,
holidays: _holidays,
startingDayOfWeek: StartingDayOfWeek.monday,
calendarStyle: CalendarStyle(
selectedColor: Colors.purple[400],
todayColor: Colors.purple[200],
markersColor: Colors.purple[700],
outsideDaysVisible: false,
),
headerStyle: HeaderStyle(
formatButtonTextStyle:
TextStyle().copyWith(color: Colors.white, fontSize: 15.0),
formatButtonDecoration: BoxDecoration(
color: Colors.purple[400],
borderRadius: BorderRadius.circular(16.0),
),
),
onDaySelected: _onDaySelected,
onVisibleDaysChanged: _onVisibleDaysChanged,
onCalendarCreated: _onCalendarCreated,
);
}
I am currently just trying to print the contents of snapshot, as I am not too sure how I will get the event information into the code, but I keep getting the type 'String' is not a subtype of type 'int' of 'index' error. If anyone would be able to identify any issues, that would be great!