dev_calendar 1.0.0 icon indicating copy to clipboard operation
dev_calendar: ^1.0.0 copied to clipboard

Dynamic calendar views.

Dev Calendar #

Example #

import 'dart:developer';

import 'package:flutter/material.dart';

import 'package:dev_calendar/dev_calendar.dart';

class CalendarView extends StatefulWidget {
  const CalendarView({Key? key}) : super(key: key);

  @override
  State<CalendarView> createState() => _CalendarViewState();
}

class _CalendarViewState extends State<CalendarView> {
  var date = Date().day;

  void changeDate(Date date) {
    setState(() {
      date = date;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Calendar View'),
      ),
      body: SizedBox(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height / 2,
        child: _buildCalendar(changeDate),
      ),
    );
  }
}

Widget _buildCalendar(Function(Date) changeDate) {
  return Calendar(
    isCustomized: false,
    weekendOpacityEnable: false,
    previous: const CircleAvatar(
      radius: 14,
      backgroundColor: Colors.white,
      child: Icon(
        Icons.arrow_back_ios,
        size: 16,
        color: Color(0xff189AB4),
      ),
    ),
    next: const CircleAvatar(
      radius: 14,
      backgroundColor: Colors.white,
      child: Icon(
        Icons.arrow_forward_ios,
        size: 16,
        color: Color(0xff189AB4),
      ),
    ),
    addOnTap: () => log('add Ontap'),
    space: 20,
    onSelected: (value) => changeDate(value!),
    backgroundColor: const Color.fromARGB(255, 255, 255, 255),
    activeColor: const Color(0xff189AB4),
    textStyleDays: TextStyle(
        fontWeight: FontWeight.normal,
        color: Colors.grey.shade800,
        fontSize: 16),
    textStyleWeekDay: const TextStyle(
      fontSize: 16,
      fontWeight: FontWeight.bold,
      color: Color(0xff189AB4),
    ),
    titleStyle: const TextStyle(
      fontWeight: FontWeight.bold,
      fontSize: 20,
    ),
    selectedStyle: const TextStyle(
      fontWeight: FontWeight.bold,
      fontSize: 14,
      color: Color.fromARGB(255, 255, 255, 255),
    ),
  );
}