xetra11
xetra11

Reputation: 8835

Is there a Widget in Flutter that is disabled after a specified timeout?

I wonder if there is some kind of widget that fades out as soon as some time passes.

Something like that:

child: Temporary(500, child: Text("I will disappear in 500ms"))

If it does not exist in a package or build-in yet - what would be a good way to solve this by myself?

Upvotes: 1

Views: 74

Answers (1)

Robert Sandberg
Robert Sandberg

Reputation: 8607

You could make use of the AnimatedOpacity widget.

There is a cookbook with detailed description. But instead of using a button to toggle the visibility, you could make use of a Timer() call which fires once, has a Duration set to 500 ms and a callback that changes the visibility boolean.

The link:

https://docs.flutter.dev/cookbook/animation/opacity-animation

Upvotes: 2

Related Questions