我想有一个旋转木马/滑动/行的元素(图像/图标)遵循路径的曲线(圆弧),我想滚动的元素在曲线路径不是在直线路径,请分享如果你有任何想法。您可以在下面的链接中查看示例:
发布于 2020-05-15 08:29:03
是的,你可以检查一下,我用的是PageView:
例如:
class _MyHomePageState extends State<MyHomePage> {
PageController _pageController =
PageController(initialPage: 0, viewportFraction: 0.2);
int pageChangedIndex = 0;
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text('Home'),
),
body: Align(
alignment: Alignment.bottomCenter,
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
Container(
height: 100.0,
color: Colors.blue,
),
PageView.builder(
itemCount: 20,
controller: _pageController,
physics: BouncingScrollPhysics(),
onPageChanged: (index) {
setState(() {
pageChangedIndex = index;
});
},
itemBuilder: (context, index) {
print(pageChangedIndex.toString() + ' ' + index.toString());
final scale = max(SCALE_FRACTION,
(FULL_SCALE - (index - pageChangedIndex).abs()) + 0.2);
return Stack(
children: <Widget>[
AnimatedPositioned(
duration: Duration(milliseconds: 600),
bottom: index - 2 == pageChangedIndex
? 10.0
: index - 1 == pageChangedIndex
? 30
: index + 1 == pageChangedIndex
? 30.0
: index + 2 == pageChangedIndex
? 10.0
: index == pageChangedIndex
? 50.0
: 10.0,
child: Container(
color: Colors.red,
// height: pageChangedIndex == index
// ? PAGER_HEIGHT * scale
// : 45.0,
// width: pageChangedIndex == index
// ? PAGER_HEIGHT * scale
// : 45.0,
child: Text('hey there'),
),
),
],
);
}),
],
),
),
);
}
}
https://stackoverflow.com/questions/59809068
复制相似问题