Flutter UI #96: Fun with Square Percent Indicater in Flutter


Fun with Square Percent Indicater in Flutter
Flutter UI #96: Fun with Square Percent Indicater in Flutter


square_percent_indicater: ^0.1.0

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:square_percent_indicater/square_percent_indicater.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(),
    );
  }
}

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

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int value = 0;
  late Timer timer;
  @override
  void initState() {
    super.initState();
    timer = Timer.periodic(const Duration(milliseconds: 20), (Timer t) {
      setState(() {
        value = (value + 1) % 100;
      });
    });
  }

  @override
  void dispose() {
    timer.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Center(child: Text("Square Percent Indicater"),),),
      body: Center(
        child: SquarePercentIndicator(
          width: 140,
          height: 140,
          reverse: true,
          borderRadius: 12,
          shadowWidth: 1.5,
          progressWidth: 4,
          shadowColor: Colors.blue,
          progressColor: Colors.pink,
          progress: value / 100,
          child: Center(
              child: Text(
                "$value %",
                style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
              )),
        ),
      ),
    );
  }
}

#fluttertutorial #fluttertutorialforbeginners #flutterkicks #flutterfullcourse #flutterapp #flutterproject #fluttercourse #flutterappdevelopment #flutteranimation #flutterapi #flutterapptutorial #flutterapiintegration #flutterappproject #flutterbloc #flutterbasics #flutterbloctutorial #flutterbeginnertutorial #flutterbackend #flutterblocpattern #flutterbackgroundservice #fluttercrashcourse #fluttercompletetutorial #cookieswirlcfluttershydoll #flutterdevelopment #flutterdesktop #flutterdownload #flutterdesign #flutterdesktopapp #flutterdart #flutterd #flutterecommerceapp #flutterexplained

7 views0 comments