Flutter,如何创建嵌入文本的边框?

mik*_*ssy 3 dart flutter flutter-layout

有谁知道如何在顶部创建一个带有文本的边框,如下所示,“创建一个帐户?

流感

Ami*_*ati 8

        Stack(
          children: <Widget>[
            Container(
              width: double.infinity,
              height: 200,
              margin: EdgeInsets.fromLTRB(20, 20, 20, 10),
              padding: EdgeInsets.only(bottom: 10),
              decoration: BoxDecoration(
                border: Border.all(
                    color: Color.fromARGB(255, 51, 204, 255), width: 1),
                borderRadius: BorderRadius.circular(5),
                shape: BoxShape.rectangle,
              ),
            ),
            Positioned(
                left: 50,
                top: 12,
                child: Container(
                  padding: EdgeInsets.only(bottom: 10, left: 10, right: 10),
                  color: Colors.white,
                  child: Text(
                    'Create an account',
                    style: TextStyle(color: Colors.black, fontSize: 12),
                  ),
                )),
          ],
        )
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

  • 哦,我看到文本的容器必须与脚手架背景的颜色相同。使用``Theme.of(context).scaffoldBackgroundColor``很容易实现 (2认同)