简体   繁体   English

flutter 中小部件的轮廓边框

[英]Outline border to widget in flutter

I want to make outline border and label to container like this我想像这样为容器制作轮廓边框和 label 在此处输入图像描述

You can do this for simulate this design.您可以这样做以模拟此设计。 It looks little bit of complicate but I can't find other way to do this.它看起来有点复杂,但我找不到其他方法来做到这一点。 Hope that it will work for you.希望它对你有用。 Just make sure the bottom and the top container colors are same as the code.只需确保底部和顶部容器 colors 与代码相同。 Just call this MyMenuContent class to see this output.只需调用此MyMenuContent class 即可查看此 output。

class MyMenuContent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
          height: MediaQuery.of(context).size.height / 2,
          padding: EdgeInsets.all(10),
          child: Stack(
            children: [
              Positioned(
                top: 50,
                child: Container(
                  height: MediaQuery.of(context).size.height / 12,
              width: MediaQuery.of(context).size.width / 2,
              decoration: BoxDecoration(
                    shape: BoxShape.rectangle,
                borderRadius: BorderRadius.circular(12),
                color: Colors.white,
                border: Border.all(
                  color: Colors.black,
                  width: 1,
                    ),
              ),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  Icon(Icons.calendar_today),
                  SizedBox(width: 10),
                  //Text
                  Text(
                    '16-12-2020',
                        style: TextStyle(
                        fontSize: 17, fontWeight: FontWeight.w500),
                  )
                    ],
                  ),
                ),
              ),
              Positioned(
            // top: 40,left: 80,
            top: MediaQuery.of(context).size.width / 9.5,
            left: MediaQuery.of(context).size.height / 7,

                child: Container(
              decoration: BoxDecoration(
                color: Colors.white,
                shape: BoxShape.rectangle,
                borderRadius: BorderRadius.circular(12),
              ),
              child: Center(
                      child: Text(
                "outline",
                style: TextStyle(fontSize: 15),
              )),
            ),
          )
        ],
      ),
    ),
  ),
    );
}
}

在此处输入图像描述

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

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