forked from ShaunRain/flutter_tindercard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.dart
75 lines (69 loc) · 2.39 KB
/
example.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import 'package:flutter/material.dart';
import 'package:flutter_tindercard/flutter_tindercard.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: ExampleHomePage(),
);
}
}
class ExampleHomePage extends StatefulWidget {
@override
_ExampleHomePageState createState() => _ExampleHomePageState();
}
class _ExampleHomePageState extends State<ExampleHomePage>
with TickerProviderStateMixin {
List<String> welcomeImages = [
"assets/welcome0.png",
"assets/welcome1.png",
"assets/welcome2.png",
"assets/welcome2.png",
"assets/welcome1.png",
"assets/welcome1.png"
];
@override
Widget build(BuildContext context) {
CardController controller; //Use this to trigger swap.
return new Scaffold(
body: new Center(
child: Container(
height: MediaQuery.of(context).size.height * 0.6,
child: new TinderSwapCard(
orientation: AmassOrientation.BOTTOM,
totalNum: welcomeImages.length,
stackNum: 3,
swipeEdge: 4.0,
maxWidth: MediaQuery.of(context).size.width * 0.9,
maxHeight: MediaQuery.of(context).size.width * 0.9,
minWidth: MediaQuery.of(context).size.width * 0.8,
minHeight: MediaQuery.of(context).size.width * 0.8,
cardBuilder: (context, index) => Card(
child: Image.asset('${welcomeImages[index]}'),
),
cardController: controller = CardController(),
swipeUpdateCallback:
(DragUpdateDetails details, Alignment align) {
/// Get swiping card's alignment
if (align.x < 0) {
//Card is LEFT swiping
} else if (align.x > 0) {
//Card is RIGHT swiping
}
},
swipeCompleteCallback:
(CardSwipeOrientation orientation, int index) {
/// Get orientation & index of swiped card!
},
),
),
),
);
}
}