Flutter 如何实现刷卡动作将彩瓦移到彩瓦号码拼图上?
这是我的密码。。 我使用gesturedetector的ontap()函数在点击按钮时移动瓷砖。我想实现滑动功能,将瓷砖移动到未着色部分Flutter 如何实现刷卡动作将彩瓦移到彩瓦号码拼图上?,flutter,flutter-layout,flutter-animation,Flutter,Flutter Layout,Flutter Animation,这是我的密码。。 我使用gesturedetector的ontap()函数在点击按钮时移动瓷砖。我想实现滑动功能,将瓷砖移动到未着色部分 main.dart Widget tiles(int i) { bool isZero = i == 0; return GestureDetector( onTap: (){ movePosition(i); }, child: ShakeView( controller: _shakeController, child
main.dart
Widget tiles(int i) {
bool isZero = i == 0;
return GestureDetector(
onTap: (){
movePosition(i);
},
child: ShakeView(
controller: _shakeController,
child: Container(
width: 125,
height: 100,
margin: EdgeInsets.all(5.0),
decoration: BoxDecoration(
color: isZero ? Colors.white : Color(0xff000080),
border: Border.all(width: 2.0),
),
child: Center(
child: Text(
'$i',
style: TextStyle(color: Colors.white, fontSize: 25),
),
),
),
),
);
}
使用
gesturedector
,您的思路是正确的。使用onPanUpdate
属性,而不是onTap
onPanUpdate
采用如下函数:
GestureDetector(onPanUpdate: (details) {
if (details.delta.dx > 0) {
// detecting swipe right
}
});
另外,请阅读这篇关于构建自定义滑块的中型文章试试动画容器。