App10 : Local Weather - Learning New Widgets

  • CircularProgressIndicator
  • A material design circular progress indicator, which spins to indicate that the application is busy.

    • Determinate : Determinate progress indicators have a specific value at each point in time, and the value should increase monotonically from 0.0 to 1.0, at which time the indicator is complete. To create a determinate progress indicator, use a non-null value between 0.0 and 1.0.

      Indeterminate : Indeterminate progress indicators do not have a specific value at each point in time and instead indicate that progress is being made without indicating how much progress remains. To create an indeterminate progress indicator, use a null value.

    Determinate Example :


     

    class MyHomePage extends StatefulWidget {

      const MyHomePage({Key? key}) : super(key: key);

     

      @override

      State<MyHomePage> createState() => _MyHomePageState();

    }

     

    class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {

      late AnimationController controller;

     

      @override

      void initState() {

        controller = AnimationController(

          vsync: this,

          duration: const Duration(seconds: 5),

        )..addListener(() {

            setState(() {});

          });

        controller.repeat(reverse: true);

        super.initState();

      }

     

      @override

      void dispose() {

        controller.dispose();

        super.dispose();

      }

     

      @override

      Widget build(BuildContext context) {

        return Scaffold(

          body: Padding(

            padding: const EdgeInsets.all(20.0),

            child: Column(

              mainAxisAlignment: MainAxisAlignment.spaceEvenly,

              children: <Widget>[

                Text(

                  'Circular progress indicator with a fixed color',

                  style: Theme.of(context).textTheme.headline6,

                ),

                CircularProgressIndicator(

                  value: controller.value,

                  semanticsLabel: 'Circular progress indicator',

                ),

              ],

            ),

          ),

        );

      }

    }






    Indeterminate Example :

     

    class MyHomePage extends StatelessWidget {

      const MyHomePage({Key? key}) : super(key: key);

     

      @override

      Widget build(BuildContext context) {

        return Scaffold(

          body: Center(child: CircularProgressIndicator()),

        );

      }

    }