Search code examples
flutterdartmobileflutter-layout

How to make a horizontal bar in flutter


enter image description here

I am trying to create a horizontal bar that grows in colour strength given the numbers supplied to it in a flutter app. Does anyone have an idea?


Solution

  • You can use row with Expanded and Text

     Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Expanded(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: SizedBox(
              height: 10,
              child: LinearProgressIndicator(
                value: 200 / 425, //current / max
    
                backgroundColor: Colors.blue.shade100,
                color: Colors.blue,
              ),
            ),
          ),
        ),
        Text("value")
      ],
    ),