Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Progress Indicator Size [duplicate]

I was wondering if there was a way to change the width/length/height of both the linear and circular progress bar. I'm trying to make a XP bar using it, but I'm not sure if that's possible. Also, I am aware the values are only through 0.0 and 1.0, but I also think it's possible(not sure) that I would be able to make a formula to where it will still work.

like image 226
aj580 Avatar asked Sep 25 '18 23:09

aj580


3 Answers

Progress indicator will fill its parent layout widget e.g

SizedBox(
    height: 300.0,
    width: 300.0,
    child: 
        CircularProgressIndicator(
        valueColor: AlwaysStoppedAnimation(Colors.blue),
        strokeWidth: 5.0)
    )
like image 176
F-1 Avatar answered Nov 15 '22 02:11

F-1


  1. With this code you decide that it is an array of Widget, if you put that is an array, it's because of the response you can give, You can have more widget to add,
  2. That is centered
  3. and what is a CircularProgressIndicator.

In this way, the Circular Progress Indicator will not take the width and height of the father that contains it

regards

<Widget>[Center(child: CircularProgressIndicator())]

like image 9
ijann Avatar answered Nov 15 '22 02:11

ijann


How can I combine a class that creates a loading indicator with my button, so that when I press it, the indicator turns on and flips to the next page?

Here the code:

class Loader extends StatefulWidget {
      @override
      State createState() => LoaderState();
    }

    class LoaderState extends State<Loader> with SingleTickerProviderStateMixin {
      AnimationController controller;
      Animation<double> animation;

      @override
      void initState() {
        super.initState();
        controller = AnimationController(
            duration: Duration(milliseconds: 1200), vsync: this);
        animation = CurvedAnimation(parent: controller, curve: Curves.elasticOut);
        animation.addListener(() {
          this.setState(() {});
        });
        animation.addStatusListener((AnimationStatus status) {});
        controller.repeat();
      }

      @override
      void dispose() {
        controller.dispose();
        super.dispose();
      }

      @override
      Widget build(BuildContext context) {
        return Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              color: Colors.blue,
              height: 3.0,
              width: animation.value * 100.0,
            ),
            Padding(
              padding: EdgeInsets.only(bottom: 5.0),
            ),
            Container(
              color: Colors.blue[300],
              height: 3.0,
              width: animation.value * 75.0,
            ),
            Padding(
              padding: EdgeInsets.only(bottom: 5.0),
            ),
            Container(
              color: Colors.blue,
              height: 3.0,
              width: animation.value * 50.0,
            )
          ],
        );
      }
    }


    Expanded(
                        child: Padding(
                          padding:
                              EdgeInsets.only(left: 20.0, right: 5.0, top:20.0),
                          child: GestureDetector(
                            onTap: () {
                              Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) => FirstScreen()));
                            },
                            child: Container(
                                alignment: Alignment.center,
                                height: 45.0,
                                decoration: BoxDecoration(
                                    color: Color(0xFF1976D2),
                                    borderRadius: BorderRadius.circular(9.0)),
                                child: Text('Login',
                                    style: TextStyle(
                                        fontSize: 20.0, color: Colors.white))),
                          ),
                        ),
                      ),
like image 1
Max Avatar answered Nov 15 '22 04:11

Max