Flutter日历轮播选择会更改日历日期

问题描述 投票:0回答:1

我正在使用1.4.0版的颤振日历轮播,并且遇到这种奇怪的行为,即当我移动月份并选择一天(仅是第一次选择)时,日历会移动1天。我附上了代码和用于日历行为的gif。

Gifhttps://i.stack.imgur.com/rGQd4.gif

代码

  DateTime _selectedDate = DateTime.now();
  EventList<Event> _markedDateMap;
  Widget _calendarWidget() {
    return Container(
      //alignment: Alignment.topLeft,
      margin: EdgeInsets.symmetric(horizontal: 50.0),
      child: CalendarCarousel<Event>(
        onDayPressed: (DateTime date, List<Event> events) {
          this.setState(() => _selectedDate = date);
        },
        weekendTextStyle: TextStyle(
          color: Colors.red,
        ),
        headerTextStyle: TextStyle(fontFamily: 'Nunito', fontWeight: FontWeight.bold, fontSize: FontSize.m, color: Colors.deepPurple),[![enter image description here][1]][1]
        selectedDayButtonColor: Colors.deepPurple,
        selectedDayBorderColor: Colors.deepPurple,
        weekFormat: false,
        markedDatesMap: _markedDateMap,
        height: MediaQuery.of(context).size.height * 0.5,
        selectedDateTime: _selectedDate,
        daysHaveCircularBorder: null, /// null for not rendering any border, true for circular border, false for rectangular border
      ),
    );
  }

flutter dart flutter-layout
1个回答
0
投票

对于可能遇到相同问题的任何人,我都做了一些尝试,而错误是由于CalendarCarousel中的“ showHeader”字段,停用了该字段并给出了自定义标头,解决了我的问题。

© www.soinside.com 2019 - 2024. All rights reserved.