Skip to main content

flexi_calendar 0.0.1 copy "flexi_calendar: ^0.0.1" to clipboard
flexi_calendar: ^0.0.1 copied to clipboard

A lightweight, configurable Flutter calendar widget focused on clarity, flexibility, and real-world use cases.

example/lib/main.dart

import 'package:flexi_calendar/flexi_calendar.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const CalendarDemoApp());
}

class CalendarDemoApp extends StatelessWidget {
  const CalendarDemoApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: CalendarDemoScreen(),
    );
  }
}

class CalendarDemoScreen extends StatefulWidget {
  const CalendarDemoScreen({super.key});

  @override
  State<CalendarDemoScreen> createState() => _CalendarDemoScreenState();
}

class _CalendarDemoScreenState extends State<CalendarDemoScreen> {
  DateTime? singleDate;
  DateTimeRange? selectedRange;
  List<DateTime> multipleDates = [];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("FlexiCalendar - All Usages")),
      body: ListView(
        padding: const EdgeInsets.all(16),

          children: [
          /// 1️⃣ Single Date Selection (No initial date)
          _title("1. Single Date Selection"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),

            ),
            onDaySelected: (date) {
              setState(() => singleDate = date);
            },
          ),
          _info("Selected: $singleDate"),

          const SizedBox(height: 40),

          /// 2️⃣ Auto Select Today
          _title("2. Auto Select Today"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
              autoSelectToday: true,
            ),
          ),

          const SizedBox(height: 40),

          /// 3️⃣ Disable Future Dates
          _title("3. Disable Future Dates"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(1900),
              lastDate: DateTime.now(),
              disableFutureDates: true,
            ),
          ),

          const SizedBox(height: 40),

          /// 4️⃣ Disable Past Dates
          _title("4. Disable Past Dates"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime.now(),
              lastDate: DateTime(2030),
              disablePastDates: true,
            ),
          ),

          const SizedBox(height: 40),

          /// 5️⃣ Range Selection
          _title("5. Range Selection"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
              selectionMode: CalendarSelectionMode.range,
              themeColor: Colors.red,
            ),
            onRangeSelected: (range) {
              setState(() => selectedRange = range);
            },
          ),
          _info("Range: ${selectedRange?.start} → ${selectedRange?.end}"),

          const SizedBox(height: 40),

          /// 6️⃣ Multiple Selection
          _title("6. Multiple Selection"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
              selectionMode: CalendarSelectionMode.multiple,
            ),
            onMultipleSelected: (dates) {
              setState(() => multipleDates = dates);
            },
          ),
          _info("Selected Dates: $multipleDates"),

          const SizedBox(height: 40),

          /// 7️⃣ Events + Dot Indicator
          _title("7. Events + Dot Indicator"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
            ),
            events: {
              DateTime(2026, 2, 3): [
                CalendarEvent(color: Colors.red),
                CalendarEvent(color: Colors.green),
              ],
              DateTime(2026, 2, 10): [
                CalendarEvent(color: Colors.blue),
              ],
            },
          ),

          const SizedBox(height: 40),

          /// 8️⃣ Week View
          _title("8. Week View"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
              calendarView: CalendarView.week,
            ),
          ),

          const SizedBox(height: 40),

          /// 9️⃣ Week View + Start Monday
          _title("9. Week View + Start Monday"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
              calendarView: CalendarView.week,
              startWeekOn: DateTime.monday,
              weekdayLabelStyle: WeekdayLabelStyle.medium,
            ),
          ),

          const SizedBox(height: 40),

          /// 🔟 Custom Text Styles
          _title("10. Custom Text Styles"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
              themeColor: Colors.black,
              textStyles: CalendarTextStyles(
                monthTextStyle: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
                yearTextStyle: const TextStyle(fontSize: 16),
                weekdayTextStyle: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
                dayTextStyle: const TextStyle(fontSize: 16, color: Colors.green),
              ),
            ),
          ),

          const SizedBox(height: 40),

          /// 1️⃣1️⃣ Header & Body Wrappers
          _title("11. Header & Body Wrappers"),
          FlexiCalendar(
            config: CalendarConfig(
              firstDate: DateTime(2020),
              lastDate: DateTime(2030),
              headerBuilder: (context, child) {
                return Container(
                  padding: const EdgeInsets.all(8),
                  decoration: BoxDecoration(
                    color: Colors.grey.shade200,
                    borderRadius: BorderRadius.circular(8),
                  ),
                  child: child,
                );
              },
              bodyBuilder: (context, child) {
                return Container(
                  padding: const EdgeInsets.all(12),
                  decoration: BoxDecoration(
                    border: Border.all(color: Colors.grey.shade400),
                    borderRadius: BorderRadius.circular(12),
                  ),
                  child: child,
                );
              },
            ),
          ),

          const SizedBox(height: 60),
        ],
      ),
    );
  }

  Widget _title(String text) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 12),
      child: Text(
        text,
        style: const TextStyle(
          fontSize: 18,
          fontWeight: FontWeight.bold,
        ),
      ),
    );
  }

  Widget _info(String text) {
    return Padding(
      padding: const EdgeInsets.only(top: 8),
      child: Text(
        text,
        style: const TextStyle(color: Colors.grey),
      ),
    );
  }
}
0
likes
150
points
34
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A lightweight, configurable Flutter calendar widget focused on clarity, flexibility, and real-world use cases.

Repository (GitHub)

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on flexi_calendar