flutter - 像在颤动中用两个按钮滑动一样的火种
问题描述
像滑动一样,但左右两个按钮
我正在使用这个包:https ://pub.dev/packages/flutter_tindercard
我不想拖动选项我希望按钮向左或向右滑动是否有可能所以请帮助我。由于特定的拖动机制(及其背后的数学)是使这张卡片如此独特地移动并且由这个家伙回购管理的原因,我想我不可能通过单击按钮手动将卡片框架操纵到侧面(在至少与实际的物理滑动不同)。
我的代码
import 'package:flutter/material.dart';
import 'package:flutter_tindercard/flutter_tindercard.dart';
import 'package:google_fonts/google_fonts.dart';
class SwipeCard extends StatefulWidget {
@override
_SwipeCardState createState() => _SwipeCardState();
}
class _SwipeCardState extends State<SwipeCard> {
List<String> numText = [
"1 of 1",
"1 of 2",
"1 of 3",
"1 of 4",
"1 of 5",
"1 of 6"
];
List<String> cardText = [
"My First Card",
"My Second Card",
"My Third Card",
"My fourth Card",
"My fifth Card",
"My Sixth Card"
];
CardController controller;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
color: Color(0xff2dedaa),
child: ListView(children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 20,
),
Row(
children: [
IconButton(
color: Colors.white,
icon: Icon(Icons.arrow_back),
onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => PageViewScreen(indexValue: 3,)));
},
iconSize: 30,
),
SizedBox(
width: 120,
),
Container(
height: 40,
width: 50,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/paw.png",
),
fit: BoxFit.fill,
))),
SizedBox(
width: 100,
),
FlatButton(
onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => PetName()));
},
child: Text('Skip',
style: GoogleFonts.roboto(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold))),
],
),
SizedBox(height: 20),
Center(
child: Container(
height: MediaQuery.of(context).size.height * 0.6,
child: new TinderSwapCard(
orientation: AmassOrientation.TOP,
totalNum: 6,
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(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
SizedBox(
height: 20,
),
Text('${numText[index]}'),
SizedBox(
height: 20,
),
Text('${cardText[index]}'),
Row(children: [
FlatButton(child: Text('yes'),onPressed: (){
},),
FlatButton(child: Text('No'),onPressed: (){
},),
],)
],
),
),
cardController: controller = CardController(),
swipeUpdateCallback:
(DragUpdateDetails details, Alignment align) {
/// Get swiping card's alignment
if (align.x < 0) {
} else if (align.x > 0) {
//Card is RIGHT swiping
}
},
swipeCompleteCallback:
(CardSwipeOrientation orientation, int index) {
/// Get orientation & index of swiped card!
}))),
],
)
])),
);
}
}
解决方案
使用这个逻辑来解决这个问题
cardText.removeAt(0);
cardText 是一个列表
TinderSwapCard(
orientation: AmassOrientation.TOP,
totalNum: cardText.length,
)
推荐阅读
- jquery - jQuery 将文本添加到 URL 的末尾
- python - 无法连接到 {}:{}".format(hostname, reason)
- javascript - 将 2 个字段链接在一起,并在组合 prisma 时使它们独一无二
- flutter - 文件未正确转换为 base64 字符串
- parameter-passing - 如何通过重力表单表单字段检索在 url 中传递的值
- java - 在 while 循环中进行多个输入时出现错误
- python - Pyqtgraph 中绘图的悬停工具
- python - 大型多维数据的无监督聚类
- reactjs - Moment.js 减法函数不适用于自定义日期
- android - 使用 customAdapter 时,带有 MultiChoiceModeListener 的 listView 不会突出显示选择项