scrolling_years_calendar_nullsafety 2.0.0-nullsafety.1
scrolling_years_calendar_nullsafety: ^2.0.0-nullsafety.1 copied to clipboard
A calendar widget to easily scroll through the years, allowing for customizations to fit your design. Forked from https://github.com/mennorenkens/flutter_scrolling_calendar
import 'package:flutter/material.dart';
import 'package:scrolling_years_calendar_nullsafety/scrolling_years_calendar.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Scrolling Years Calendar',
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
List<DateTime> getHighlightedDates() {
return List<DateTime>.generate(
10,
(int index) => DateTime.now().add(Duration(days: 10 * (index + 1))),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter Scrolling Calendar'),
),
body: Center(
child: ScrollingYearsCalendar(
// Required parameters
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now().subtract(const Duration(days: 5 * 365)),
lastDate: DateTime.now(),
currentDateColor: Colors.blue,
// Optional parameters
highlightedDates: getHighlightedDates(),
highlightedDateColor: Colors.deepOrange,
monthNames: const <String>[
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
],
onMonthTap: (int year, int month) => print('Tapped $month/$year'),
monthTitleStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
),
),
);
}
}