Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change direction of LinearProgressIndicator to vertical

Tags:

flutter

Is there a way I can change the direction of the LinearProgressIndicator from horizontal to vertical?

I can change the size of it like this:

Container(
  height: 1000,
  width: 24,
  child: LinearProgressIndicator(
    value: 0.8,
  ),
),

But the the progress will still go from right to left. Can I somehow change it from top to bottom?

like image 883
Jonas Avatar asked Jan 25 '26 03:01

Jonas


2 Answers

While LinearProgressIndicator does not support this directly, you can easily wrap it with RotatedBox to rotate it 90 degrees, either clockwise (1) or counter-clockwise (-1), for example:

RotatedBox(
  quarterTurns: -1,
  child: LinearProgressIndicator(),
)

You can further customize it like usual, of course height becomes width and etc, example result:

example screenshot

Full source for the above example:

Padding(
  padding: EdgeInsets.all(80),
  child: Row(
    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
    children: [
      RotatedBox(
        quarterTurns: -1,
        child: LinearProgressIndicator(
          value: 0.12,
        ),
      ),
      RotatedBox(
        quarterTurns: -1,
        child: LinearProgressIndicator(
          value: 0.42,
          valueColor: AlwaysStoppedAnimation(Colors.orange),
          backgroundColor: Colors.blue,
        ),
      ),
      RotatedBox(
        quarterTurns: 1,
        child: LinearProgressIndicator(
          minHeight: 20,
          value: 0.89,
          valueColor: AlwaysStoppedAnimation(Colors.purple),
          backgroundColor: Colors.lime,
        ),
      ),
    ],
  ),
)
like image 147
user1032613 Avatar answered Jan 27 '26 20:01

user1032613


please use this package https://pub.dev/packages/flutter_animation_progress_bar
it support vertical progress bar.

code snippet

import 'package:flutter/widgets.dart';
import 'package:flutter_animation_progress_bar/flutter_animation_progress_bar.dart';

void main() {
  runApp(
    Center(
        child: FAProgressBar(
          direction: Axis.vertical,
          verticalDirection: VerticalDirection.up,
      currentValue: 80,
      displayText: '%',
    )),
  );
}

code snippet demo

enter image description here

official demo
enter image description here

like image 32
chunhunghan Avatar answered Jan 27 '26 19:01

chunhunghan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!