如何在颤抖中将一个容器夹在另一个容器上?

安全南达

我想构建一个可重复使用的卡片小部件,它将具有带有某些自定义设计布局的图像和文本。我尽了一切努力,但未能达到预期的效果。任何帮助将非常感激。这就是我想做的

我被困在这里

This is my code 


class ReusabelCard extends StatelessWidget {
  ReusabelCard(
      {this.cardChild, @required this.assetImagePath, @required this.cardText});
  final Widget cardChild;
  final String assetImagePath;
  final String cardText;
  @override
  Widget build(BuildContext context) {
    return Container(
        height: MediaQuery.of(context).size.height * 0.35,
        width: MediaQuery.of(context).size.width * 0.5,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(MediaQuery.of(context).size.width * 0.5 * 0.28),
        ),
        child: Stack(
          children: [
            LayoutBuilder(
              builder: (context, contraint) {
                return Column(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    Icon(
                      Icons.trip_origin,
                      size: contraint.biggest.width,
                      color: Colors.grey[300],
                    ),
                    Container(
                      height: MediaQuery.of(context).size.height*0.05,
                      width: MediaQuery.of(context).size.width,
                      color: Colors.green,
                    ),
                  ],
                );
              },
            ),
          ],
        )
        
        );
  }
}
洛夫

使用ClipRRect它来做:

ClipRRect(
  borderRadius: BorderRadius.circular(50.0), //clipping the whole widget
  child: Container(
    height: MediaQuery.of(context).size.height * 0.4, //I adjusted here for responsiveness problems on my device
    width: MediaQuery.of(context).size.width * 0.5,
    color: Colors.white,
    child: LayoutBuilder(
      builder: (context, constraint) {
        return Stack(
          children: [
            Center(
              child: Icon(
                Icons.trip_origin,
                size: constraint.biggest.width,
                color: Colors.grey[300],
              ),
            ),
            Positioned(
              right: 0,
              left: 0,
              top: 20.0,
              child: Icon(
                Icons.sports_volleyball_rounded, //just to represent the ball
                size: constraint.biggest.width * 0.5,
              ),
            ),
            Positioned(
              bottom: 0.0,
              child: Container(
                alignment: Alignment.center,
                height: MediaQuery.of(context).size.height * 0.1,
                width: constraint.biggest.width,
                color: Colors.yellow[700],
                child: Text(
                  'Sports',
                  style: Theme.of(context)
                      .textTheme
                      .headline3
                      .copyWith(color: Colors.white),
                ),
              ),
            ),
          ],
        );
      },
    ),
  ),
);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在css中将一个容器放在另一个容器之上?

如何在Docker中将流量从一个容器路由到另一个容器

如何在 Docker Compose 中将端口从一个容器转发到另一个容器?

如何在JavaFX中将容器从一个窗口转移到另一个窗口

如何访问容器中的另一个容器

如何从另一个容器访问容器视图

如何在选项卡中将div容器放置在另一个div容器内

如何在颤抖中将一个有状态的小部件的状态从另一个状态更改为?

如何在长按选择的 GridView 项目上显示另一个容器

如何在Docker中将数据从一个容器获取到另一个容器?我收到ECONNREFUSED错误

如何在同一个docker-compose文件中将数据库从couchdb容器映射到另一个容器webapp

如何在移动视图中使一个容器下推另一个容器?

Docker,如何在PHP中的另一个容器中获取容器IP?

如何在构建另一个容器的过程中填充Mysql docker容器?

一个Docker容器如何调用另一个Docker容器

如何使一个容器填充另一个容器剩下的空间?

如何从另一个容器中得到一个容器?

一个容器在另一个之上?

如何从dockerized nginx到达另一个容器

如何从另一个容器连接到服务?

如何在传递REST查询时触发容器启动另一个容器并终止该容器?

将容器DNS暴露给另一个容器?

从另一个容器访问Docker容器

管理来自另一个容器的容器docker

从另一个容器访问Docker postgres容器

部署另一个容器后重启容器

从另一个容器内部对容器运行命令

从另一个容器访问的Docker容器端口

在另一个容器docker中执行另一个容器命令