如何创建自定义堆栈中的条子出现在颤动中?

时间:2019-09-20 09:09:47

标签: android flutter dart flutter-layout flutter-sliver

大家好,我正在为Flutter应用创建个人资料页面。

SliverAppBar处于展开状态时需要显示以下视图:

Header with profile image in a RED circle

当用户滚动白名单时,在视图下方。

scrolled header with profile picture overflowing the header

如您所见,这是我可以创建的自定义堆栈。

我不知道如何在颤动中切成薄片。

特别感谢您深入了解有关颤振和条子的任何链接。

折叠后的堆栈的代码:

             Stack(
                  alignment: Alignment.topRight,
                  children: <Widget>[
                    Container(
                        margin: EdgeInsets.only(top: 12),
                        width: 2000,
                        height: 80,
                        decoration: BoxDecoration(boxShadow: [
                          BoxShadow(blurRadius: 5.0, color: Colors.black87)
                        ])),
                    Container(
                      margin: EdgeInsets.only(right: 20, top: 5),
                      decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          boxShadow: [
                            BoxShadow(blurRadius: 5.0, color: Colors.black87)
                          ],
                          border: Border.all(color: Colors.cyan, width: 3.0)),
                      child: CircleAvatar(
                        backgroundImage: AssetImage(
                            "assets/images/food/avocado-f.jpg"),

                        radius: 50,
                      ),
                    )
                  ],
                ),

1 个答案:

答案 0 :(得分:0)

您应该使用$product = Product::create([ "product" => $request->product, "price" => $request->price, "stock" => $request->stcok, "description" => $request->description, ]); 并创建自己的SliverPersistentHeader

在构建方法中,添加“堆栈”视图,然后可以使用Transform或SizedBox来缩放和变换圆形,具体取决于标题的高度。

有一个很好的教程,解释了如何使用此小部件 https://medium.com/flutter-community/how-to-code-a-dynamic-header-in-flutter-e171ec2231bf