如何将容器中的图像设置为颤动的背景

艾哈迈德·明哈(Ahmed Minhaj)

我要设计一个自定义组件卡,该组件卡中附有一张图像,标题部分将在图像部分重叠,并且说明将添加到图像部分的下面。如何在图像中重叠显示文本?

class CardWithImage extends StatelessWidget {
  final String title, buttonText;
  final String subTitle;
  final String body;
  final asset;

  CardWithImage({
    this.title,
    this.subTitle,
    this.body,
    this.asset,
    this.buttonText,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: MediaQuery.of(context).size.width,
      margin: EdgeInsets.all(15),
      decoration: BoxDecoration(
        color: ThemeColors.primaryColor,
        borderRadius: BorderRadius.circular(5),
        boxShadow: [
          BoxShadow(
            color: ThemeColors.grey5,
            blurRadius: 10,
            spreadRadius: 5,
            offset: Offset(3, 3),
          )
        ],
      ),
      child: Column(
        children: <Widget>[
          Image.asset(
            asset,
            height: 200,
            width: MediaQuery.of(context).size.width,
            fit: BoxFit.cover,
          ),

        ],
      ),
    );
  }
}

我想创建一张像这样的卡片

维伦·瓦拉萨迪亚(Viren V Varasadiya)

您可以使用以下代码实现您的愿望卡。

Container(
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Container(
          height: 200,
          decoration: BoxDecoration(
            image: DecorationImage(
                image: AssetImage('assets/images/background.png'),
                fit: BoxFit.cover),
          ),
          child: Align(
            alignment: Alignment.bottomCenter,
            child: Container(
              color: Colors.grey.withOpacity(0.3),
              height: 50,
              width: MediaQuery.of(context).size.width,
              child: Align(
                alignment: Alignment.centerLeft,
                child: Text(
                  "Title",
                ),
              ),
            ),
          ),
        ),
        Container(
          padding: EdgeInsets.all(10),
          child: Text(
            "Your Big Text ",
            textAlign: TextAlign.left,
          ),
        )
      ],
    ),
  ),

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

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

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Swing:如何将组件高度设置为容器的高度?

用脚手架将容器包装为渐变背景如何将渐变设置为容器背景?

如何将AlertDialog设置为不关闭颤动中的外部单击

如何将图像设置为UIImage

如何将多行文字与为:before设置的背景图像垂直对齐

如何将图像设置为NSCollectionView?

颤振如何将容器背景设置为透明颜色

如何将背景图像设置为源文件夹中的图像?

如何将背景色设置为包含颤动文本的宽度

缩放图像后如何将图像限制在容器中?

如何将焦点设置在颤动中的材质按钮上

如何将容器的maxWidth设置为100%>>全局

如何将图像设置为div

如何将精灵设置为背景图像?

如何将OnClickListener设置为背景?

如何将画布的大小设置为其背景图像?

如何将图像设置为pdf页面背景

将图像设置为背景

如何将按钮的背景图像设置为左对齐?

如何将海龟设置为图像

如何将背景图像设置为画布

如何将背景图像宽度设置为边到边

如何将图像按钮设置为我的内部存储 (Android) 中的某些图像?

如何将 URL 检索到的图像宽度调整为 React Native 中的视图容器?

如何将背景图像设置为仅屏幕左半部分

如何将背景图像设置为 blob url

如何将图像设置为画布背景而不是在 Android Studio/JavaScript 中填充颜色

如何将图像的背景颜色设置为黑色?

我如何使容器小部件中的背景图像在颤动中发生变化