【问题标题】:How to achieve "instagram camera" scrolling in flutter?如何实现“instagram 相机”在颤动中滚动?
【发布时间】:2019-12-13 20:01:14
【问题描述】:

我正在尝试在 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 到达末尾时,如何向 PageView 发送 onDrag 事件?

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    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),
              ]
          )
    
        ],
      ),
    

    【讨论】:

    • 但是现在如果我有多个 Container 在 Wrap 我不能全部滚动它们
    猜你喜欢
    • 2021-07-22
    • 1970-01-01
    • 2018-12-19
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    • 2021-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多