chore: upgrade min sdk version to 3.0.0
This commit is contained in:
parent
bea7ea77a5
commit
7b79e303f7
|
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
|
## [7.0.0]
|
||||||
|
|
||||||
|
- **BREAKING CHANGE**:
|
||||||
|
- Upgrade min dart sdk to 3.0.0
|
||||||
|
|
||||||
## [6.1.0]
|
## [6.1.0]
|
||||||
|
|
||||||
- Fixes cannot access context in onSwipe when no cards left then "destroy" the widget tree
|
- Fixes cannot access context in onSwipe when no cards left then "destroy" the widget tree
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ class ExampleCard extends StatelessWidget {
|
||||||
|
|
||||||
const ExampleCard(
|
const ExampleCard(
|
||||||
this.candidate, {
|
this.candidate, {
|
||||||
Key? key,
|
super.key,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ void main() {
|
||||||
|
|
||||||
class Example extends StatefulWidget {
|
class Example extends StatefulWidget {
|
||||||
const Example({
|
const Example({
|
||||||
Key? key,
|
super.key,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Example> createState() => _ExamplePageState();
|
State<Example> createState() => _ExamplePageState();
|
||||||
|
|
@ -65,10 +65,6 @@ class _ExamplePageState extends State<Example> {
|
||||||
onPressed: controller.undo,
|
onPressed: controller.undo,
|
||||||
child: const Icon(Icons.rotate_left),
|
child: const Icon(Icons.rotate_left),
|
||||||
),
|
),
|
||||||
FloatingActionButton(
|
|
||||||
onPressed: controller.swipe,
|
|
||||||
child: const Icon(Icons.rotate_right),
|
|
||||||
),
|
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onPressed: controller.swipeLeft,
|
onPressed: controller.swipeLeft,
|
||||||
child: const Icon(Icons.keyboard_arrow_left),
|
child: const Icon(Icons.keyboard_arrow_left),
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ publish_to: "none"
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.15.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
|
|
|
||||||
|
|
@ -136,18 +136,13 @@ class CardAnimation {
|
||||||
}
|
}
|
||||||
|
|
||||||
void animate(BuildContext context, CardSwiperDirection direction) {
|
void animate(BuildContext context, CardSwiperDirection direction) {
|
||||||
switch (direction) {
|
return switch (direction) {
|
||||||
case CardSwiperDirection.left:
|
CardSwiperDirection.left => animateHorizontally(context, false),
|
||||||
return animateHorizontally(context, false);
|
CardSwiperDirection.right => animateHorizontally(context, true),
|
||||||
case CardSwiperDirection.right:
|
CardSwiperDirection.top => animateVertically(context, false),
|
||||||
return animateHorizontally(context, true);
|
CardSwiperDirection.bottom => animateVertically(context, true),
|
||||||
case CardSwiperDirection.top:
|
CardSwiperDirection.none => null,
|
||||||
return animateVertically(context, false);
|
};
|
||||||
case CardSwiperDirection.bottom:
|
|
||||||
return animateVertically(context, true);
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void animateHorizontally(BuildContext context, bool isToRight) {
|
void animateHorizontally(BuildContext context, bool isToRight) {
|
||||||
|
|
@ -215,18 +210,13 @@ class CardAnimation {
|
||||||
}
|
}
|
||||||
|
|
||||||
void animateUndo(BuildContext context, CardSwiperDirection direction) {
|
void animateUndo(BuildContext context, CardSwiperDirection direction) {
|
||||||
switch (direction) {
|
return switch (direction) {
|
||||||
case CardSwiperDirection.left:
|
CardSwiperDirection.left => animateUndoHorizontally(context, false),
|
||||||
return animateUndoHorizontally(context, false);
|
CardSwiperDirection.right => animateUndoHorizontally(context, true),
|
||||||
case CardSwiperDirection.right:
|
CardSwiperDirection.top => animateUndoVertically(context, false),
|
||||||
return animateUndoHorizontally(context, true);
|
CardSwiperDirection.bottom => animateUndoVertically(context, true),
|
||||||
case CardSwiperDirection.top:
|
_ => null
|
||||||
return animateUndoVertically(context, false);
|
};
|
||||||
case CardSwiperDirection.bottom:
|
|
||||||
return animateUndoVertically(context, true);
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void animateUndoHorizontally(BuildContext context, bool isToRight) {
|
void animateUndoHorizontally(BuildContext context, bool isToRight) {
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,11 @@ import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_card_swiper/src/enums.dart';
|
import 'package:flutter_card_swiper/src/enums.dart';
|
||||||
|
|
||||||
extension DirectionExtension on CardSwiperDirection {
|
extension DirectionExtension on CardSwiperDirection {
|
||||||
Axis get axis {
|
Axis get axis => switch (this) {
|
||||||
switch (this) {
|
CardSwiperDirection.left ||
|
||||||
case CardSwiperDirection.left:
|
CardSwiperDirection.right =>
|
||||||
case CardSwiperDirection.right:
|
Axis.horizontal,
|
||||||
return Axis.horizontal;
|
CardSwiperDirection.top || CardSwiperDirection.bottom => Axis.vertical,
|
||||||
case CardSwiperDirection.top:
|
CardSwiperDirection.none => throw Exception('Direction is none'),
|
||||||
case CardSwiperDirection.bottom:
|
};
|
||||||
return Axis.vertical;
|
|
||||||
case CardSwiperDirection.none:
|
|
||||||
throw Exception('Direction is none');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,6 @@ class CardSwiper extends StatefulWidget {
|
||||||
const CardSwiper({
|
const CardSwiper({
|
||||||
required this.cardBuilder,
|
required this.cardBuilder,
|
||||||
required this.cardsCount,
|
required this.cardsCount,
|
||||||
Key? key,
|
|
||||||
this.controller,
|
this.controller,
|
||||||
this.initialIndex = 0,
|
this.initialIndex = 0,
|
||||||
this.padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 25),
|
this.padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 25),
|
||||||
|
|
@ -150,6 +149,7 @@ class CardSwiper extends StatefulWidget {
|
||||||
this.numberOfCardsDisplayed = 2,
|
this.numberOfCardsDisplayed = 2,
|
||||||
this.onUndo,
|
this.onUndo,
|
||||||
this.backCardOffset = const Offset(0, 40),
|
this.backCardOffset = const Offset(0, 40),
|
||||||
|
super.key,
|
||||||
}) : assert(
|
}) : assert(
|
||||||
maxAngle >= 0 && maxAngle <= 360,
|
maxAngle >= 0 && maxAngle <= 360,
|
||||||
'maxAngle must be between 0 and 360',
|
'maxAngle must be between 0 and 360',
|
||||||
|
|
@ -173,8 +173,7 @@ class CardSwiper extends StatefulWidget {
|
||||||
assert(
|
assert(
|
||||||
initialIndex >= 0 && initialIndex < cardsCount,
|
initialIndex >= 0 && initialIndex < cardsCount,
|
||||||
'initialIndex must be between 0 and [cardsCount]',
|
'initialIndex must be between 0 and [cardsCount]',
|
||||||
),
|
);
|
||||||
super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State createState() => _CardSwiperState();
|
State createState() => _CardSwiperState();
|
||||||
|
|
|
||||||
|
|
@ -46,27 +46,21 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
|
||||||
}
|
}
|
||||||
|
|
||||||
void onSwipeDirectionChanged(CardSwiperDirection direction) {
|
void onSwipeDirectionChanged(CardSwiperDirection direction) {
|
||||||
if (direction == CardSwiperDirection.none) {
|
switch (direction) {
|
||||||
|
case CardSwiperDirection.none:
|
||||||
_detectedVerticalDirection = direction;
|
_detectedVerticalDirection = direction;
|
||||||
_detectedHorizontalDirection = direction;
|
_detectedHorizontalDirection = direction;
|
||||||
widget.onSwipeDirectionChange
|
case CardSwiperDirection.right:
|
||||||
?.call(_detectedHorizontalDirection, _detectedVerticalDirection);
|
case CardSwiperDirection.left:
|
||||||
} else if (direction == CardSwiperDirection.right ||
|
|
||||||
direction == CardSwiperDirection.left) {
|
|
||||||
if (_detectedHorizontalDirection != direction) {
|
|
||||||
_detectedHorizontalDirection = direction;
|
_detectedHorizontalDirection = direction;
|
||||||
widget.onSwipeDirectionChange
|
case CardSwiperDirection.top:
|
||||||
?.call(_detectedHorizontalDirection, _detectedVerticalDirection);
|
case CardSwiperDirection.bottom:
|
||||||
}
|
|
||||||
} else if (direction == CardSwiperDirection.top ||
|
|
||||||
direction == CardSwiperDirection.bottom) {
|
|
||||||
if (_detectedVerticalDirection != direction) {
|
|
||||||
_detectedVerticalDirection = direction;
|
_detectedVerticalDirection = direction;
|
||||||
|
}
|
||||||
|
|
||||||
widget.onSwipeDirectionChange
|
widget.onSwipeDirectionChange
|
||||||
?.call(_detectedHorizontalDirection, _detectedVerticalDirection);
|
?.call(_detectedHorizontalDirection, _detectedVerticalDirection);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
|
@ -193,7 +187,6 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
|
||||||
switch (_swipeType) {
|
switch (_swipeType) {
|
||||||
case SwipeType.swipe:
|
case SwipeType.swipe:
|
||||||
await _handleCompleteSwipe();
|
await _handleCompleteSwipe();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -256,18 +249,13 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isValidDirection(CardSwiperDirection direction) {
|
bool _isValidDirection(CardSwiperDirection direction) {
|
||||||
switch (direction) {
|
return switch (direction) {
|
||||||
case CardSwiperDirection.left:
|
CardSwiperDirection.left => widget.allowedSwipeDirection.left,
|
||||||
return widget.allowedSwipeDirection.left;
|
CardSwiperDirection.right => widget.allowedSwipeDirection.right,
|
||||||
case CardSwiperDirection.right:
|
CardSwiperDirection.top => widget.allowedSwipeDirection.up,
|
||||||
return widget.allowedSwipeDirection.right;
|
CardSwiperDirection.bottom => widget.allowedSwipeDirection.down,
|
||||||
case CardSwiperDirection.top:
|
_ => false
|
||||||
return widget.allowedSwipeDirection.up;
|
};
|
||||||
case CardSwiperDirection.bottom:
|
|
||||||
return widget.allowedSwipeDirection.down;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _swipe(CardSwiperDirection direction) {
|
void _swipe(CardSwiperDirection direction) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ issue_tracker: https://github.com/ricardodalarme/flutter_card_swiper/issues
|
||||||
version: 6.1.0
|
version: 6.1.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
flutter: ">=1.17.0"
|
flutter: ">=1.17.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue