Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customDayBuilder is broken #270

Closed
trygvis opened this issue Mar 26, 2021 · 0 comments
Closed

customDayBuilder is broken #270

trygvis opened this issue Mar 26, 2021 · 0 comments

Comments

@trygvis
Copy link
Contributor

trygvis commented Mar 26, 2021

Version of flutter_calendar_carousel

2.0.0

Expected behavior

After #260 customDayBuilder can not return null. There is also no way to return the default implementation which could have been an alternative, but as it's nullability is documented as a feature I suspect this happened by accident. Link to diff

I haven't looked at the other custom builders, but being able to return null if one doesn't want to customize the widget is useful. We want to customize the current day, and have the default behavior for all other days.

Suggested new implementation of getDayContainer():

Widget getDayContainer(
    bool isSelectable,
    int index,
    bool isSelectedDay,
    bool isToday,
    bool isPrevMonthDay,
    TextStyle? textStyle,
    TextStyle defaultTextStyle,
    bool isNextMonthDay,
    bool isThisMonthDay,
    DateTime now) {
  final customDayBuilder = widget.customDayBuilder;
  Widget? widget;
  if (customDayBuilder != null) {
    final TextStyle appTextStyle = DefaultTextStyle.of(context).style;
    TextStyle styleForBuilder = appTextStyle.merge(getDayStyle(
        isSelectable,
        index,
        isSelectedDay,
        isToday,
        isPrevMonthDay,
        textStyle,
        defaultTextStyle,
        isNextMonthDay,
        isThisMonthDay));

    widget = customDayBuilder(isSelectable, index, isSelectedDay, isToday,
        isPrevMonthDay, styleForBuilder, isNextMonthDay, isThisMonthDay, now);
  }

  return widget ?? getDefaultDayContainer(
      isSelectable,
      index,
      isSelectedDay,
      isToday,
      isPrevMonthDay,
      textStyle,
      defaultTextStyle,
      isNextMonthDay,
      isThisMonthDay,
      now);
}
trygvis added a commit to trygvis/flutter_calendar_carousel that referenced this issue Apr 7, 2021
Allow customDayBuilder and markedDateIconBuilder to return null. If it
returns null, use the default. This restores the original behavior from
v1. Fixes hyochan#270.
@hyochan hyochan closed this as completed in 89f1f4d Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant