Changing time format in syncfusion_flutter_calendar

70 views Asked by At

I am using the package syncfusion_flutter_calendar in a Flutter app. Here you have a screenshot from the agenda part of CalendarView.month

enter image description here

Here you have the complete code for the SFCalendar widget:

 body: SfCalendar(
          firstDayOfWeek: 1,
          view: CalendarView.month,
          monthViewSettings: MonthViewSettings(
            appointmentDisplayMode: MonthAppointmentDisplayMode.indicator,
            showAgenda: true,
          ),
          dataSource: EventDataSource(events),
          initialSelectedDate: DateTime.now(),
          cellBorderColor: Colors.blueGrey,
          timeSlotViewSettings: TimeSlotViewSettings(
            timeFormat:
                'HH:mm', // Esto cambiará el formato de las horas a 24 horas
          ),
          onSelectionChanged: (details) {
            final provider = Provider.of<EventProvider>(context, listen: false);

            provider.setDate(details.date!);
          },
          onTap: (details) {
            final provider = Provider.of<EventProvider>(context, listen: false);

            if (provider.selectedDate == details.date) {
              showModalBottomSheet(
                context: context,
                builder: (context) => TasksWidget(),
              );
            }
          },
          onLongPress: (details) {
            final provider = Provider.of<EventProvider>(context, listen: false);

            provider.setDate(details.date!);
            showModalBottomSheet(
              context: context,
              builder: (context) => TasksWidget(),
            );
          },
        ),

I would like to show initial time and end time in 24h format, I am not able to find out how to do it, I have searched the syncfusion documentation for the Agenda part of the calendar view but anything found.

1

There are 1 answers

1
Mauro Casse On

You should check the Intl package.

I think the time format you're looking for is HH:mm format

Hope this helps