Add border to a Container with borderRadius in Flutter

后端 未结 4 804
臣服心动
臣服心动 2021-02-03 21:01
Container(
      child: Text(
          \'This is a Container\',
          textScaleFactor: 2,
          style: TextStyle(color: Colors.black),
      ),

      decoratio         


        
4条回答
  •  忘掉有多难
    2021-02-03 21:15

    There are a couple ways to add a border to a Flutter widget. The most basic way is to wrap your widget in a DecoratedBox. However, the Container widget also has a DecoratedBox built in.

    For output as above use a Stack instead of Row because of Stack allows us to make multiple widgets overlay each other and you can align or position your widget using the Align or Positioned widget.

     Container(
      height: 65,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(10),
        color: Colors.deepPurple.shade100,
      ),
      child: Stack(
        children: [
          Container(
            width: 8,
    
            decoration: BoxDecoration(
              borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(15),
                  bottomLeft: Radius.circular(15)),
              color: Colors.deepPurple,
            ),
          )
        ],
      ),
    )
    

提交回复
热议问题