You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

87 lines
2.3 KiB

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:table_calendar/table_calendar.dart';
class CalendarPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _CalendarPage();
}
}
class _CalendarPage extends State<CalendarPage> with TickerProviderStateMixin {
AnimationController _animationController;
CalendarController _calendarController;
@override
void initState() {
super.initState();
_calendarController = CalendarController();
_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 400),
);
_animationController.forward();
}
@override
void dispose() {
_animationController.dispose();
_calendarController.dispose();
super.dispose();
}
void _onDaySelected(DateTime day, List events, List holidays) {
print('CALLBACK: _onDaySelected');
}
void _onVisibleDaysChanged(DateTime first, DateTime last, CalendarFormat format) {
print('CALLBACK: _onVisibleDaysChanged');
}
void _onCalendarCreated(DateTime first, DateTime last, CalendarFormat format) {
print('CALLBACK: _onCalendarCreated');
}
@override
Widget build(BuildContext context) {
return Container(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
_buildTableCalendar(),
],
),
);
}
Widget _buildTableCalendar() {
return TableCalendar(
calendarController: _calendarController,
startingDayOfWeek: StartingDayOfWeek.monday,
availableGestures: AvailableGestures.none,
headerStyle: HeaderStyle(
centerHeaderTitle: false,
leftChevronVisible: false,
rightChevronVisible: false,
formatButtonVisible: false,
),
calendarStyle: CalendarStyle(
outsideDaysVisible: false,
selectedColor: Color(0xFF32A060),
weekendStyle: TextStyle().copyWith(color: Color(0xFF333333)),
todayColor: Color(0xFFD5EBDE),
),
daysOfWeekStyle: DaysOfWeekStyle(
weekendStyle: TextStyle().copyWith(color: Color(0xFF4D4D4D)),
),
onDaySelected: _onDaySelected,
onVisibleDaysChanged: _onVisibleDaysChanged,
onCalendarCreated: _onCalendarCreated,
);
}
}