如何在扩展小部件中拉伸容器?

时间:2019-12-13 13:29:56

标签: flutter flutter-layout flutter-animation

这是我的代码:

Expanded(
  child: Transform.translate(
    offset: Offset(0, -40),
    child: Container(
      width: double.infinity,
      padding: EdgeInsets.only(top: 30, left: 30, right: 30, bottom: 10),
      decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(30),
              topRight: Radius.circular(30))),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          FadeAnimation(
            1.2,
            Text(
              menuDay.meals[currentIndex].name,
              style: TextStyle(
                color: Colors.grey[800],
                fontSize: 26,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
          SizedBox(
            height: 25,
          ),
          Row(
            children: <Widget>[
              FadeAnimation(
                1.4,
                Text(
                  menuDay.meals[currentIndex].price,
                  style: TextStyle(
                    color: Colors.yellow[700],
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
              SizedBox(
                width: 20,
              ),
              FadeAnimation(
                1.7,
                Row(
                  children: <Widget>[
                    Icon(
                      Icons.star,
                      size: 20,
                      color: Colors.yellow[700],
                    ),
                    Icon(
                      Icons.star,
                      size: 20,
                      color: Colors.yellow[700],
                    ),
                    Icon(
                      Icons.star,
                      size: 20,
                      color: Colors.yellow[700],
                    ),
                    Icon(
                      Icons.star,
                      size: 20,
                      color: Colors.yellow[700],
                    ),
                    Icon(
                      Icons.star_half,
                      size: 20,
                      color: Colors.yellow[700],
                    ),
                  ],
                ),
              ),
            ],
          ),
        ],
      ),
    ),
  ),
)

如何在扩展小部件中拉伸容器?

我看不到我的饭菜价格和星星。我知道问题是-40的偏移量,但是我不知道如何在没有偏移的情况下创建相同的布局。

Container

Expanded

0 个答案:

没有答案