1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import 'package:flutter/material.dart';
import 'package:table_calendar/table_calendar.dart';
class EventsScreen extends StatefulWidget {
const EventsScreen({super.key});
@override
State<EventsScreen> createState() => _EventsScreenState();
}
class _EventsScreenState extends State<EventsScreen> {
DateTime _selectedDay = DateTime.now();
DateTime _focusedDay = DateTime.now();
CalendarFormat _calendarFormat = CalendarFormat.month;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Eventos'),
actions: const [],
),
body: Container(
child: TableCalendar(
firstDay: DateTime.fromMicrosecondsSinceEpoch(0),
lastDay: DateTime.utc(9000, 12, 31),
focusedDay: _focusedDay,
selectedDayPredicate: (day) {
return isSameDay(_selectedDay, day);
},
onDaySelected: (selectedDay, focusedDay) {
setState(() {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
},
calendarFormat: _calendarFormat,
onFormatChanged: (format) {
setState(() {
_calendarFormat = format;
});
},
)),
floatingActionButton: FloatingActionButton.extended(
label: const Text('Nuevo'),
icon: const Icon(Icons.add),
onPressed: () {
Navigator.of(context).pushNamed('/newevent');
},
),
);
}
}
|