diegoveloper / flutter_percent_indicator

Flutter percent indicator library
BSD 2-Clause "Simplified" License
677 stars 206 forks source link

Animation hangs when the widget is just launched #204

Open rocboronat opened 10 months ago

rocboronat commented 10 months ago

For some reason, when the screen that shows the indicator is launched, the animation of the indicator feels janky. It makes a big jump for some millis.

As I didn't know what was working wrong, I made an example project to check it, and yes: the issue is in the package itself.

Feel free to copy paste this example, and tap the circle. It will launch a new screen with a new circle, and you will see the jank.

By the way, thanks for this piece of magic! 😄

import 'package:flutter/material.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

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

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Center(
      child: GestureDetector(
        onTap: () => Navigator.of(context).push(
          MaterialPageRoute(builder: (context) => const MyHomePage()),
        ),
        child: CircularPercentIndicator(
          radius: 83,
          percent: 0.83,
          animation: true,
          animationDuration: const Duration(seconds: 3).inMilliseconds,
        ),
      ),
    ));
  }
}

Oh, and here's a video to show the effect:

https://github.com/diegoveloper/flutter_percent_indicator/assets/456499/20bea118-c33d-4707-9196-b1ae095b33b6