-3

我想制作一个自定义容器/卡片,如下所示:

预期结果

如何在颤动中实现重叠/重叠布局?

4

2 回答 2

2

使用 Stack 小部件和 Positioned 小部件,这有助于将小部件放在堆栈中您想要的任何位置

于 2020-06-23T11:25:54.377 回答
0

代码:

Container(
  width: 135.0,
  height: 80.0,
  margin: EdgeInsets.only(right: 5.0),
  child: Stack(
    children: [
      Align(
        alignment: Alignment.centerLeft,
        child: Container(
          width: 110.0,
          height: 150.0,
          decoration: BoxDecoration(
            color: Colors.white,
            shape: BoxShape.rectangle,
            borderRadius: BorderRadius.all(Radius.circular(20.0)),
          ),
          child: Align(
            alignment: Alignment.bottomLeft,
            child: Padding(
              padding: EdgeInsets.only(left: 15.0, bottom: 20.0),
              child: Text(
                text,
                style: TextStyle(
                  fontSize: 15.0,
                  fontFamily: 'PlayfairDisplay',
                  color: kInactiveSearchPageTextColor,
                ),
              ),
            ),
          ),
        ),
      ),
      Align(
        alignment: Alignment.topLeft,
        child: Image.asset(
          image,
          width: 110,
          height: 110,
        ),
      ),
      Positioned(
        top: 162,
        left: 90,
        child: Container(
          width: 41.0,
          height: 41.0,
          child: RawMaterialButton(
            fillColor: Colors.white,
            shape: CircleBorder(),
            elevation: 12.0,
            child: Icon(
              Icons.add,
              color: kActiveSearchPageButtonColor,
            ),
            onPressed: onPressed,
          ),
        ),
      ),
    ],
  ),
);
于 2020-06-24T10:46:50.117 回答