How to Open a View after Delay In Flutter?

· 2 min read
How to Open a View after Delay In Flutter
How to Open a View after Delay In Flutter

Generally, an application requires a short span of time to open an application. Sometimes users may be required to display data after performing some action on the application. In that kind of situation, we need to Open a View after a delay in Flutter. So in this article, we will learn about How to Open a View after Delay In Flutter?

How to Open a View after Delay In Flutter?

There are two ways to achieve the same.

We will understand each Step by Step.

Using Timer Class: A count-down timer that can be configured to fire once or repeatedly. Consider a code snippet like below:

First import a package like below:

import 'dart:async';
Timer(Duration(seconds: 5), () {
  // 5s over, navigate to a new page
  Navigator.pushNamed(context, MaterialPageRoute(builder: (_) => Screen2()));
});

In the Above case, the user would be redirected to the new screen after a delay of 5 seconds.

Future.delayed(Duration(seconds: 5), () {
  // 5s over, navigate to a new page
  Navigator.pushNamed(context, MaterialPageRoute(builder: (_) => Screen2()));
});

In the Above case, the user would be redirected to the new screen after a delay of 5 seconds. user can define a time in various formats like in milliseconds, microseconds as per end-user requirements.

Conclusion:

Thanks for being with us on a Flutter Journey !!!

Keep Learning !!! Keep Fluttering !!!

Do Share Your Valuable Feedback to Serve you better.

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portal dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge on Flutter.

Leave a Reply