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

问题描述 投票:0回答:1

我正在尝试使用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?

flutter flutter-layout
1个回答
0
投票

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

PageView(
    scrollDirection: Axis.vertical,
    children:[
      Container(color: Colors.red),
      Wrap(
          children:[
            Container(color: Colors.yellow, height:300),
            Container(color: Colors.green, height:300),
          ]
      )

    ],
  ),
© www.soinside.com 2019 - 2024. All rights reserved.