如何实现“ instagram相机”在抖动中滚动?

时间:2019-12-13 20:01:14

标签: flutter flutter-layout

我正在尝试在PageView中使用ScrollView来实现这种效果:

https://ibb.co/dMd3TZL

但是,当我滚动到第二页时,我被卡住了,无法返回了。

示例代码:

    import 'package:flutter/material.dart';

    void main() => runApp(MyApp());

    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: Scaffold(
            appBar: AppBar(
              title: Text("Demo"),
            ),
            body: PageView(
              scrollDirection: Axis.vertical,
              children:[
                Container(color: Colors.red),
                ListView(
                  children:[
                    Container(color: Colors.yellow, height:300),
                    Container(color: Colors.green, height:300),
                  ]
                )
              ],
            ),
          ),
        );
      }
    }

当ScrollView到达末尾时,如何将onDrag事件发送到PageView?

1 个答案:

答案 0 :(得分:0)

listview不能与pageviewer一起使用,因此请使用wrap Widget而不是listview,

     Group{

        ForEach(circleArray) { wordArray in
            Text("\(wordArray.words)")
                .animation(Animation.easeInOut.delay(0.5))
        }

        Text("like")
            .animation(Animation.easeInOut.delay(0.5))

        Text("This")
            .animation(Animation.easeInOut.delay(1))


    }.frame(width: UIScreen.main.bounds.width)