appinio_swiper 1.1.0 appinio_swiper: ^1.1.0 copied to clipboard
An awesome fully custamisable Tinder Card Swiper which allows swiping in all directions with any Custom Widget (Stateless or Statefull).
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:appinio_swiper/appinio_swiper.dart';
import 'package:example/example_candidate_model.dart';
import 'package:example/example_card.dart';
import 'example_buttons.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return const CupertinoApp(
debugShowCheckedModeBanner: false,
home: Example(),
);
}
}
class Example extends StatefulWidget {
const Example({
Key? key,
}) : super(key: key);
@override
State<Example> createState() => _ExamplePageState();
}
class _ExamplePageState extends State<Example> {
final AppinioSwiperController controller = AppinioSwiperController();
List<ExampleCard> cards = [];
@override
void initState() {
_loadCards();
super.initState();
}
void _loadCards() {
for (ExampleCandidateModel candidate in candidates) {
cards.add(
ExampleCard(
candidate: candidate,
),
);
}
}
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Column(
children: [
const SizedBox(
height: 50,
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.75,
child: AppinioSwiper(
unlimitedUnswipe: true,
controller: controller,
unswipe: _unswipe,
cards: cards,
onSwipe: _swipe,
padding: const EdgeInsets.only(
left: 25,
right: 25,
top: 50,
bottom: 40,
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(
width: 80,
),
swipeLeftButton(controller),
const SizedBox(
width: 20,
),
swipeRightButton(controller),
const SizedBox(
width: 20,
),
unswipeButton(controller),
],
)
],
),
);
}
void _swipe(int index, AppinioSwiperDirection direction) {
log("the card was swiped to the: " + direction.name);
}
void _unswipe(bool unswiped) {
if (unswiped) {
log("SUCCESS: card was unswiped");
} else {
log("FAIL: no card left to unswipe");
}
}
}