Flutter 带日历抖动的Tindercard刷卡

Flutter 带日历抖动的Tindercard刷卡,flutter,calendar,swipe,Flutter,Calendar,Swipe,是否有任何库可用于使用日历视图刷卡。虽然刷它应该打开下个月的日历。我们有图书馆打火刷卡和日历分开,可以合并在一起,但不能打开下个月刷卡。我们有没有办法做到这一点,或者我们需要创建自己的视图日历 @override Widget build(BuildContext context) { return Expanded( child: Stack( children: <Widget>[ backCard(), middleCard(),

是否有任何库可用于使用日历视图刷卡。虽然刷它应该打开下个月的日历。我们有图书馆打火刷卡和日历分开,可以合并在一起,但不能打开下个月刷卡。我们有没有办法做到这一点,或者我们需要创建自己的视图日历

   @override
  Widget build(BuildContext context) {
  return 
  Expanded(
    child: Stack(
  children: <Widget>[
    backCard(),
    middleCard(),
    frontCard(),

    // Prevent swiping if the cards are animating
    _controller.status != AnimationStatus.forward
        ? SizedBox.expand(
            child: GestureDetector(
            // While dragging the first card
            onPanUpdate: (DragUpdateDetails details) {
              // Add what the user swiped in the last frame to the alignment of the card
              setState(() {
                // 20 is the "speed" at which moves the card
                frontCardAlign = Alignment(
                    frontCardAlign.x +
                        20 *
                            details.delta.dx /
                            MediaQuery.of(context).size.width,
                    frontCardAlign.y +
                        40 *
                            details.delta.dy /
                            MediaQuery.of(context).size.height);

                frontCardRot = frontCardAlign.x; // * rotation speed;
              });
            },
            // When releasing the first card
            onPanEnd: (_) {
              // If the front card was swiped far enough to count as swiped
              if (frontCardAlign.x > 3.0 || frontCardAlign.x < -3.0) {
                animateCards();
              } else {
                // Return to the initial rotation and alignment
                setState(() {
                  frontCardAlign = defaultFrontCardAlign;
                  frontCardRot = 0.0;
                });
              }
            },
          ))
        : Container(),
  ],
));
    }


  class ProfileCardAlignment extends StatelessWidget {
      final int cardNum;
       ProfileCardAlignment(this.cardNum);
       String _selectedDate;
     String _dateCount;
       String _range;
       String _rangeCount;

     @override
    void initState() {
     _selectedDate = '';
        _dateCount = '';
        _range = '';
      _rangeCount = '';

     }
   @override
      Widget build(BuildContext context) {
     return Card(
      child: Stack(
    children: <Widget>[
    /*  SizedBox.expand(
        child: Material(
          borderRadius: BorderRadius.circular(12.0),
          child: Image.asset('res/portrait.jpeg', fit: BoxFit.cover),
        ),
      ),
      SizedBox.expand(
        child: Container(
          decoration: BoxDecoration(
              gradient: LinearGradient(
                  colors: [Colors.transparent, Colors.black54],
                  begin: Alignment.center,
                  end: Alignment.bottomCenter)),
        ),
                 ),*/
           Align(
        alignment: Alignment.bottomLeft,
        child:
        Container(
            padding: EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.end,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                /*Text('Card number $cardNum',
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 20.0,
                        fontWeight: FontWeight.w700)),
                Padding(padding: EdgeInsets.only(bottom: 8.0)),
                Text('A short description.',
                    textAlign: TextAlign.start,
                    style: TextStyle(color: Colors.white)),*/
                Container(
                  height: 400,
                  child:  SfDateRangePicker(
                    headerStyle: DateRangePickerHeaderStyle(textAlign: TextAlign.center),
                    onSelectionChanged: _onSelectionChanged,
                    selectionMode: DateRangePickerSelectionMode.range,
                    rangeSelectionColor: Colors.blue,

                    rangeTextStyle: TextStyle(color: Colors.white),
                    initialSelectedRange: PickerDateRange(
                        DateTime.now().subtract(const Duration(days: 2)),
                        DateTime.now().add(const Duration(days: 2))),

                  ),
                )
                    ],
                     )),
                )
               ],
              ),
              );
        }
        /// The method for [DateRangePickerSelectionChanged] callback, which will be
      /// called whenever a selection changed on the date picker widget.
        void _onSelectionChanged(DateRangePickerSelectionChangedArgs args) {
      /// The argument value will return the changed date as [DateTime] when the
        /// widget [SfDateRangeSelectionMode] set as single.
       ///
    /// The argument value will return the changed dates as [List<DateTime>]
     /// when the widget [SfDateRangeSelectionMode] set as multiple.
       ///
    /// The argument value will return the changed range as [PickerDateRange]
     /// when the widget [SfDateRangeSelectionMode] set as range.
      ///
       /// The argument value will return the changed ranges as
      /// [List<PickerDateRange] when the widget [SfDateRangeSelectionMode] set as
       /// multi range.
       /* setState(() {
        if (args.value is PickerDateRange) {
            _range =
             DateFormat('dd/MM/yyyy').format(args.value.startDate).toString() +
            ' - ' +
            DateFormat('dd/MM/yyyy')
                .format(args.value.endDate ?? args.value.startDate)
                .toString();
  } else if (args.value is DateTime) {
    _selectedDate = args.value;
  } else if (args.value is List<DateTime>) {
    _dateCount = args.value.length.toString();
  } else {
    _rangeCount = args.value.length.toString();
  }
});*/
 }
  }
@覆盖
小部件构建(构建上下文){
返回
扩大(
子:堆栈(
儿童:[
backCard(),
middleCard(),
frontCard(),
//如果卡正在设置动画,则防止刷卡
_controller.status!=AnimationStatus.forward
?SizedBox.expand(
儿童:手势检测器(
//拖动第一张卡片时
onPanUpdate:(DragUpdate详细信息){
//将用户在最后一帧中刷卡的内容添加到卡的对齐中
设置状态(){
//20是移动卡的“速度”
frontCardAlign=对齐(
frontCardAlign.x+
20 *
details.delta.dx/
MediaQuery.of(context).size.width,
frontCardAlign.y+
40 *
details.delta.dy/
MediaQuery.of(context.size.height);
frontCardRot=frontCardAlign.x;//*转速;
});
},
//当释放第一张卡时
onPanEnd:(){
//如果前面的卡被刷得足够远,可以算作被刷了
如果(frontCardAlign.x>3.0 | | frontCardAlign.x<-3.0){
animateCards();
}否则{
//返回到初始旋转和对齐状态
设置状态(){
frontCardAlign=默认的frontCardAlign;
frontCardRot=0.0;
});
}
},
))
:Container(),
],
));
}
类ProfileCardAlignment扩展了无状态小部件{
最终整数cardNum;
ProfileCardAlignment(this.cardNum);
字符串_selectedDate;
字符串_dateCount;
字符串范围;
字符串_rangeCount;
@凌驾
void initState(){
_selectedDate='';
_日期计数=“”;
_范围='';
_rangeCount='';
}
@凌驾
小部件构建(构建上下文){
回程卡(
子:堆栈(
儿童:[
/*SizedBox.expand(
儿童:材料(
边界半径:边界半径。圆形(12.0),
子项:Image.asset('res/肖像.jpeg',fit:BoxFit.cover),
),
),
SizedBox.expand(
子:容器(
装饰:盒子装饰(
梯度:线性梯度(
颜色:[颜色.透明,颜色.黑色54],
开始:Alignment.center,
结束:对齐。底部中心),
),
),*/
对齐(
对齐:对齐。左下角,
儿童:
容器(
填充:边缘组。对称(垂直:16.0,水平:16.0),
子:列(
mainAxisAlignment:mainAxisAlignment.end,
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
/*文本('卡号$cardNum',
样式:TextStyle(
颜色:颜色,白色,
字体大小:20.0,
fontWeight:fontWeight.w700),
填充(填充:仅限边集(底部:8.0)),
Text('简短描述',
textAlign:textAlign.start,
样式:TextStyle(颜色:Colors.white))*/
容器(
身高:400,
子项:SfDateRangePicker(
headerStyle:DateRangePickerHeaderStyle(textAlign:textAlign.center),
onSelectionChanged:_onSelectionChanged,
selectionMode:DateRangePickerSelectionMode.range,
rangeSelectionColor:Colors.blue,
rangeTextStyle:TextStyle(颜色:Colors.white),
initialSelectedRange:PickerDaterRange(
DateTime.now().subtract(常量持续时间(天:2)),
DateTime.now().add(常量持续时间(天:2)),
),
)
],
)),
)
],
),
);
}
///[DateRangePickerSelectionChanged]回调的方法,将
///每当日期选择器小部件上的选择发生更改时调用。
void _onSelectionChanged(日期范围选择器SelectionChangedArgs){
///参数值将在
///小部件[SfDateRangeSelectionMode]设置为单个。
///
///参数值将以[列表]的形式返回更改的日期
///当小部件[SfDateRangeSelectionMode]设置为多个时。
///
///参数值将以[PickerDaterRange]的形式返回更改的范围
///当小部件[SfDateRangeSelectionMode]设置为范围时。
///
///参数值将返回更改的范围,如下所示:
///[列表