I watched a video about Syncfusion Calendar, and while it worked as an independent widget, it kind of never works when we tried implementing it for our application. It yields us with either a blank screen or the Appbar and the FloatingActionButton appearing only. How can I make it visible?
Mind the fact that we are not making this widget the main page and has to be accessible from the dashboard itself.
class CalendarTeacherPage extends StatefulWidget {
const CalendarTeacherPage({Key? key}) : super(key: key);
@override
_CalendarTeacherPageState createState() => _CalendarTeacherPageState();
}
class _CalendarTeacherPageState extends State<CalendarTeacherPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(child: const CalendarWidget()),
appBar: AppBar(
title: const Text('Calendar'),
centerTitle: true,
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add, color: Colors.white),
backgroundColor: Colors.red,
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const EventEditingPage()),
),
),
);
}
}
This one is for our CalendarWidget, which we believe to be holding the errors.
class CalendarWidget extends StatelessWidget {
const CalendarWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final events = Provider.of<EventProvider>(context).events;
return SfCalendar(
view: CalendarView.schedule,
dataSource: EventDataSource(events),
initialSelectedDate: DateTime.now(),
cellBorderColor: Colors.transparent,
onLongPress: (details) {
final provider = Provider.of<EventProvider>(context, listen: true);
provider.setDate(details.date!);
showModalBottomSheet(
context: context,
builder: (context) => const TasksWidget(),
);
},
);
}
}
Migrating this code from the SfCalendar acting as the main widget to it being part of our dashboard has proven difficult, and I just know that the issue is in the SfCalendar and where I am placing it. How do I fix this?