Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should not flicker #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix: should not flicker #21

wants to merge 1 commit into from

Conversation

Tienisto
Copy link

@Tienisto Tienisto commented Jun 29, 2024

When the widget is initially not visible, then there is one frame where the animated widget takes the full screen.

Reproduction code:

class FlickeringTestWidget extends StatefulWidget {
  const FlickeringTestWidget({super.key});

  @override
  State<FlickeringTestWidget> createState() => _FlickeringTestWidgetState();
}

class _FlickeringTestWidgetState extends State<FlickeringTestWidget> {
  double topPadding = 0;
  bool visible = false;

  @override
  void initState() {
    super.initState();

    Future.delayed(const Duration(milliseconds: 1000), () {
      setState(() {
        visible = true;
      });
    });

    Future.delayed(const Duration(milliseconds: 2000), () {
      setState(() {
        topPadding = 100;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Opacity(
      opacity: visible ? 1 : 0,
      child: LocalHeroScope(
        child: Align(
          alignment: Alignment.topLeft,
          child: Padding(
            padding: EdgeInsets.only(top: topPadding),
            child: LocalHero(
              tag: 'id',
              child: Container(
                width: 100,
                height: 100,
                color: Colors.red,
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant