简体   繁体   English

如何使用 flutter 在卡片中设计卡片,就像这个例子一样

[英]How to design card in a card as a like this example using flutter

I want to design like this..我想这样设计。。

在此处输入图像描述

My output我的 output

在此处输入图像描述

I tried to resize the red box of the send picture like the first picture but I couldn't.我试图像第一张图片一样调整发送图片的红色框的大小,但我做不到。 How to solve it?如何解决? If cannot do like this please give your suggestions.如果不能这样做,请提出您的建议。

code代码

Card(
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(18.0),
                ),
                shadowColor: Colors.white,
                color: HexColor('#FFFBFB').withOpacity(0.5),
                child: SizedBox(
                  height: height * 0.35,
                  width: width * 0.94,
                  child: Padding(
                    padding: const EdgeInsets.only(
                        top: 0, bottom: 0, right: 0, left: 0),
                    child: Column(
                      children: <Widget>[
                        Card(
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(2.0),
                            ),
                            shadowColor: Colors.red,
                            color: HexColor('##D70040').withOpacity(0.9),
                            child: SizedBox(
                              height: height * 0.05,
                              width: (MediaQuery.of(context).size.width),
                            )),
                        Expanded(
                          child: SingleChildScrollView(
                            scrollDirection: Axis.vertical,
                            child: Padding(
                              padding: const EdgeInsets.only(
                                  top: 5, right: 10, left: 10),
                              child: Column(
                                children: <Widget>[],
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),

I dont know why you are using nested card but i think container is better solution:我不知道你为什么使用嵌套卡,但我认为容器是更好的解决方案:

Container(
          width: 400,
          height: 300,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(20),
            color: Colors.white.withOpacity(0.6),
          ),
          child: Column(
            children: [
              Container(
                width: double.infinity,
                height: 60,
                decoration: const BoxDecoration(
                  color: Colors.red,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(20),
                    topRight: Radius.circular(20),
                  ),
                ),
              )
            ],
          ),
        ),

result be like:结果就像:

在此处输入图像描述

You can play with values to get what you need你可以玩弄价值来获得你需要的东西

Here is something I managed to achieve:这是我设法实现的目标:

图片

Using this code:使用此代码:

 Column(
                children: [
                  Material(
                    child: SizedBox(
                      width: 200,
                      height: 30,
                    ),
                    color: Colors.red,
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(2).copyWith(
                        topLeft: Radius.circular(12),
                        topRight: Radius.circular(12)
                      )
                    ),
                  ),
                  Material(
                    child: SizedBox(
                      width: 200,
                      height: 80,
                    ),
                    color: Colors.white,
                     shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(2).copyWith(
                        bottomLeft: Radius.circular(12),
                        bottomRight: Radius.circular(12)
                      )
                    ),
                  )
                ],
              ),
             

Hope this helps.希望这可以帮助。 Of course you'd need to adjust colors and sizes to the ones you need in your project.当然,您需要将 colors 和大小调整为项目中所需的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM