Skip to content

fix: should not flicker#21

Open
Tienisto wants to merge 1 commit into
letsar:masterfrom
Tienisto:master
Open

fix: should not flicker#21
Tienisto wants to merge 1 commit into
letsar:masterfrom
Tienisto:master

Conversation

@Tienisto
Copy link
Copy Markdown

@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