因此,我使用 flutter 的 table_calendar 包创建了一个基本日历。
import 'package:flutter/material.dart';
import 'package:table_calendar/table_calendar.dart';
class Calendar extends StatefulWidget {
@override
_CalendarState createState() => _CalendarState();
}
class _CalendarState extends State<Calendar> {
CalendarFormat format = CalendarFormat.month;
DateTime selectedDay = DateTime.now();
DateTime focusedDay = DateTime.now();
TextEditingController _eventController = TextEditingController();
@override
void dispose() {
_eventController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("ESTech Calendar"),
centerTitle: true,
),
body: Column(
children: [
//defining min an max years
TableCalendar(
focusedDay: selectedDay,
firstDay: DateTime(1990),
lastDay: DateTime(2050),
//changing …Run Code Online (Sandbox Code Playgroud)