zenled / calendar_views

Collection of customisable calendar related widgets for Flutter.
https://pub.dartlang.org/packages/calendar_views
MIT License
102 stars 49 forks source link

how can we get on dateSelected() ? . Please help me. #6

Closed HongsengNhoem closed 5 years ago

zenled commented 5 years ago

I would need some more details to give you a better answer.

If you are trying to detect when the user clicks on a date in MonthView, you pass a dayOfMonthBuilder to MonthView. All the click detection should happen in the widget produced by dayOfMonthBuilder.

Your code should look something like this:

// ... somewhere in `Widget build(BuildContext context){`

new MonthView(
    month: _month,
    dayOfMonthBuilder: _dayOfMonthBuilder,
),

// ...

Widget _dayOfMonthBuilder(BuildContext context, DayOfMonth dayOfMonth) {
    return GestureDetector(
        onTap: () {
            // user clicked on a day of month
        },
        child: new Container(
            child: new Center(
                child: new Text("${dayOfMonth.day.day}"),
            ),
        )
    );
}