[SOLVED] How to create a custom border like this in Flutter? – Stack Overflow

Issue

This Content is from Stack Overflow. Question asked by Akhil George

I need a border for 25%,50%,75% and 100%
Required Result



Solution

You can custom it with Stack of Containers like this:

  Widget _widget({int percent = 25}) {
    return Center(
      child: Stack(
        children: [
          Positioned.fill(
            child: Row(
              children: [
                Flexible(
                  flex: percent,
                  child: Container(
                    decoration: const BoxDecoration(
                      color: Colors.green,
                      borderRadius: BorderRadius.only(topLeft: Radius.circular(30), bottomLeft: Radius.circular(30)),
                    ),
                  ),
                ),
                Flexible(
                  flex: 100 - percent,
                  child: Container(
                    decoration: BoxDecoration(
                      color: Colors.grey[300],
                      borderRadius: BorderRadius.only(topRight: Radius.circular(30), bottomRight: Radius.circular(30)),
                    ),
                  ),
                ),
              ],
            ),
          ),
          Container(
            decoration: const BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(30)),
            ),
            margin: const EdgeInsets.all(8),
            padding: const EdgeInsets.fromLTRB(25, 13, 25, 13),
            child: Text('${percent}% Complete'),
          )
        ],
      ),
    );
  }


This Question was asked in StackOverflow by Akhil George and Answered by manhtuan21 It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?