简体   繁体   English

如何在 Flutter 中设计卡片小部件

[英]How to design card widget in flutter

在此处输入图像描述

I'm trying to design a student dashboard , and am wondering how to add the blue color at the end of this card widget where the text( student, news ) are inserted ?我正在尝试设计一个学生仪表板,并且想知道如何在插入文本(学生、新闻)的卡片小部件末尾添加蓝色?

Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(12),
            color: Colors.white,
            boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(0.5),
                spreadRadius: 5,
                blurRadius: 7,
                offset: Offset(0, 3),
              ),
            ],
          ),
          child: Column(
            children: [
              Container(
                child: Icon(Icons.person, size: 24, color:Colors.blueAccent),
                padding: const EdgeInsets.all(12),
              ),
              Container(
                decoration: const BoxDecoration(
                  color: Colors.blueAccent,
                  borderRadius: BorderRadius.only(bottomRight: Radius.circular(12), bottomLeft: Radius.circular(12))
                ),
                child: Text("Student"),
                padding: const EdgeInsets.all(12),
              )
            ],
          ),
        )

output:输出: 在此处输入图像描述

You can do你可以做

Card(
  child: Column(
    children: [
      Expanded(
        flex: 3,
        child: Container(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children:[
              //custom widgets
              Icon(...),
              Text(...) 
            ]
          )
        )
      ),
      Expanded(
        child: Container(
           decoration: BoxDecoration(color: Colors.blue[900]),
           child: Center(
              child: Text(...)//custom text and style
           )
        )
      )
    ]
  )
);
Widget getCardItem() {
        return Center(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Container(
              height: 100,
              width: 105,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(12),
                color: Colors.white,
                boxShadow: [
                  BoxShadow(
                    color: Colors.grey.withOpacity(0.5),
                    spreadRadius: 5,
                    blurRadius: 7,
                    offset: Offset(0, 3),
                  ),
                ],
              ),
              child: Column(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    mainAxisSize: MainAxisSize.max,
                    children: [
                      Container(
                        child: Icon(Icons.supervisor_account,
                            size: 24, color: Colors.blueAccent),
                        padding: const EdgeInsets.all(12),
                      ),
                      Container(
                        child: Text(
                          "2100",
                          style: TextStyle(
                            color: Colors.blueAccent,
                          ),
                        ),
                        padding: const EdgeInsets.all(12),
                      ),
                    ],
                  ),
                  Container(
                    decoration: const BoxDecoration(
                        color: Colors.blueAccent,
                        borderRadius: BorderRadius.only(
                            bottomRight: Radius.circular(12),
                            bottomLeft: Radius.circular(12))),
                    child: Text("Student"),
                    padding: const EdgeInsets.all(12),
                  )
                ],
              ),
            ),
          ),
        );
      }

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

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