【问题标题】:How to push image out from the view in flutter?如何在颤动中将图像从视图中推出?
【发布时间】:2021-05-05 11:52:44
【问题描述】:

我是 Flutter 的新手,我想知道如何在我的项目中实现这种设计。

  1. 如何转换/平移背景以使其从视图中升起和升起?
  2. 如何在几毫秒后在背景顶部添加另一个容器(位于屏幕底部)?

gif demonstrating the design I'd like to achieve

【问题讨论】:

    标签: flutter flutter-layout flutter-animation


    【解决方案1】:

    使用 showModalBottomSheet。这是一个例子

     onPressed: () {
                  showModalBottomSheet(
                      context: context,
                      builder: (BuildContext ctx) {
                        return Container(
                          padding: EdgeInsets.only(top: 20),
                          child: Container() //add any widget here
                        );
                  
                      });
                }
    

    对于第一个问题,将您的图像放入 AnimatedAlign 小部件中

    【讨论】:

      【解决方案2】:

      你可以用这个,sliding_up_panel 有视差效果:

      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text("SlidingUpPanelExample"),
          ),
          body: SlidingUpPanel(
            parallaxEnabled: true,
            panel: Center(
              child: Text("This is the sliding Widget"),
            ),
            body: Center(
              child: Text("This is the Widget behind the sliding panel"),
            ),
          ),
        );
      }
      

      【讨论】:

        猜你喜欢
        • 2019-02-09
        • 2020-02-03
        • 1970-01-01
        • 2019-05-28
        • 1970-01-01
        • 2021-11-25
        • 2023-02-10
        • 1970-01-01
        • 2021-04-13
        相关资源
        最近更新 更多